activemq-cpp-3.9.5
ActiveMQConnectionFactory.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef _ACTIVEMQ_CORE_ACTIVEMQCONNECTIONFACTORY_H_
18#define _ACTIVEMQ_CORE_ACTIVEMQCONNECTIONFACTORY_H_
19
21
23#include <cms/Connection.h>
24
26
27#include <decaf/net/URI.h>
29
30namespace activemq {
31namespace core {
32
33 using decaf::lang::Pointer;
34
36 class FactorySettings;
37 class PrefetchPolicy;
38 class RedeliveryPolicy;
39
40 class AMQCPP_API ActiveMQConnectionFactory : public cms::ConnectionFactory {
41 public:
42
43 // Default Broker URI if none specified 'failover:tcp://localhost:61616'
44 static const std::string DEFAULT_URI;
45
46 private:
47
48 FactorySettings* settings;
49
50 private:
51
52 ActiveMQConnectionFactory(const ActiveMQConnectionFactory&);
53 ActiveMQConnectionFactory& operator=(const ActiveMQConnectionFactory&);
54
55 public:
56
58
69 ActiveMQConnectionFactory(const std::string& uri,
70 const std::string& username = "",
71 const std::string& password = "");
72
84 const std::string& username = "",
85 const std::string& password = "");
86
88
100
120 virtual cms::Connection* createConnection(const std::string& username,
121 const std::string& password);
122
145 virtual cms::Connection* createConnection(const std::string& username,
146 const std::string& password,
147 const std::string& clientId);
148
149 public: // Configuration Options
150
155 void setUsername(const std::string& username);
156
162 const std::string& getUsername() const;
163
168 void setPassword(const std::string& password);
169
175 const std::string& getPassword() const;
176
181 std::string getClientId() const;
182
187 void setClientId(const std::string& clientId);
188
195 void setBrokerURI(const std::string& uri);
196
204
211
221
229
238
245
255
262
272
279
283 bool isDispatchAsync() const;
284
293 void setDispatchAsync(bool value);
294
300 bool isAlwaysSyncSend() const;
301
307 void setAlwaysSyncSend(bool value);
308
313 bool isUseAsyncSend() const;
314
319 void setUseAsyncSend(bool value);
320
327 bool isSendAcksAsync() const;
328
336 void setSendAcksAsync(bool sendAcksAsync);
337
342 bool isUseCompression() const;
343
350 void setUseCompression(bool value);
351
361 void setCompressionLevel(int value);
362
369
374 unsigned int getSendTimeout() const;
375
381 void setSendTimeout(unsigned int timeout);
382
387 unsigned int getConnectResponseTimeout() const;
388
395 void setConnectResponseTimeout(unsigned int connectResponseTimeout);
396
401 unsigned int getCloseTimeout() const;
402
407 void setCloseTimeout(unsigned int timeout);
408
416 unsigned int getProducerWindowSize() const;
417
424 void setProducerWindowSize(unsigned int windowSize);
425
431
440
447
456 void setUseRetroactiveConsumer(bool useRetroactiveConsumer);
457
464
472 void setExclusiveConsumer(bool exclusiveConsumer);
473
481
489 void setWatchTopicAdvisories(bool value);
490
499 int getAuditDepth() const;
500
510 void setAuditDepth(int auditDepth);
511
518
525 void setAuditMaximumProducerNumber(int auditMaximumProducerNumber);
526
540
554 void setCheckForDuplicates(bool checkForDuplicates);
555
564
573 void setTransactedIndividualAck(bool transactedIndividualAck);
574
582
591 void setNonBlockingRedelivery(bool nonBlockingRedelivery);
592
599
607
612
619 void setOptimizeAcknowledge(bool optimizeAcknowledge);
620
627
634 void setOptimizeAcknowledgeTimeOut(long long optimizeAcknowledgeTimeOut);
635
645
655 void setOptimizedAckScheduledAckInterval(long long optimizedAckScheduledAckInterval);
656
663
673 void setAlwaysSessionAsync(bool alwaysSessionAsync);
674
679
687 void setConsumerExpiryCheckEnabled(bool consumerExpiryCheckEnabled);
688
689 public:
690
707 static cms::Connection* createConnection(const std::string& uri, const std::string& username,
708 const std::string& password, const std::string& clientId = "");
709
710 protected:
711
725 const Pointer<decaf::util::Properties>& properties);
726
727 private:
728
729 cms::Connection* doCreateConnection(const decaf::net::URI& uri, const std::string& username,
730 const std::string& password, const std::string& clientId);
731
732 void configureConnection(ActiveMQConnection* connection);
733
734 };
735
736}}
737
738#endif /*_ACTIVEMQ_CORE_ACTIVEMQCONNECTIONFACTORY_H_*/
#define AMQCPP_API
Definition Config.h:30
void setRedeliveryPolicy(RedeliveryPolicy *policy)
Sets the RedeliveryPolicy instance that this factory should use when it creates new Connection instan...
void setSendAcksAsync(bool sendAcksAsync)
Sets whether Message acknowledgments are sent asynchronously meaning no response is required from the...
void setAlwaysSyncSend(bool value)
Sets if the Connection should always send things Synchronously.
void setDispatchAsync(bool value)
Should messages be dispatched synchronously or asynchronously from the producer thread for non-durabl...
bool isSendAcksAsync() const
Returns whether Message acknowledgments are sent asynchronously meaning no response is required from ...
void setMessagePrioritySupported(bool value)
Set whether or not this factory should create Connection objects with the Message priority support fu...
void setUseCompression(bool value)
Sets whether Message body compression is enabled.
PrefetchPolicy * getPrefetchPolicy() const
Gets the pointer to the current PrefetchPolicy that is in use by this ConnectionFactory.
bool isExclusiveConsumer() const
Should all created consumers be exclusive.
const std::string & getUsername() const
Gets the username that this factory will use when creating a new connection instance.
virtual void setMessageTransformer(cms::MessageTransformer *transformer)
Set an MessageTransformer instance that is passed on to all Connection objects created from this Conn...
unsigned int getProducerWindowSize() const
Gets the configured producer window size for Producers that are created from this connector.
bool isUseCompression() const
Gets if the Connection is configured for Message body compression.
bool isUseAsyncSend() const
Gets if the useAsyncSend option is set.
RedeliveryPolicy * getRedeliveryPolicy() const
Gets the pointer to the current RedeliveryPolicy that is in use by this ConnectionFactory.
ActiveMQConnectionFactory(const decaf::net::URI &uri, const std::string &username="", const std::string &password="")
Constructor.
void setConsumerFailoverRedeliveryWaitPeriod(long long value)
Sets the delay period for a consumer redelivery.
void setAuditDepth(int auditDepth)
Set the audit depth for Messages for consumers when using a fault tolerant transport.
void setTransactedIndividualAck(bool transactedIndividualAck)
when true, submit individual transacted acks immediately rather than with transaction completion.
void setUseAsyncSend(bool value)
Sets the useAsyncSend option.
unsigned int getConnectResponseTimeout() const
Gets the assigned connect response timeout for this Connector.
long long getOptimizedAckScheduledAckInterval() const
Gets the configured time interval that is used to force all MessageConsumers that have optimizedAckno...
virtual cms::MessageTransformer * getMessageTransformer() const
Gets the currently configured MessageTransformer for this ConnectionFactory.
void setOptimizedAckScheduledAckInterval(long long optimizedAckScheduledAckInterval)
Sets the amount of time between scheduled sends of any outstanding Message Acks for consumers that ha...
std::string getClientId() const
Gets the Configured Client Id.
void setCloseTimeout(unsigned int timeout)
Sets the close timeout to use when sending the disconnect request.
bool isWatchTopicAdvisories() const
Is the Connection created by this factory configured to watch for advisory messages that inform the C...
void setProducerWindowSize(unsigned int windowSize)
Sets the size in Bytes of messages that a producer can send before it is blocked to await a ProducerA...
void setUsername(const std::string &username)
Sets the username that should be used when creating a new connection.
bool isCheckForDuplicates() const
Gets the value of the configured Duplicate Message detection feature.
void setBrokerURI(const std::string &uri)
Sets the Broker URI that should be used when creating a new connection instance.
void setAuditMaximumProducerNumber(int auditMaximumProducerNumber)
The number of Producers that will be audited.
virtual cms::ExceptionListener * getExceptionListener() const
Returns the currently set ExceptionListener that will be set on any new Connection instance that is c...
void setSendTimeout(unsigned int timeout)
Sets the send timeout to use when sending Message objects, this will cause all messages to be sent us...
void setPassword(const std::string &password)
Sets the password that should be used when creating a new connection.
int getAuditMaximumProducerNumber() const
The number of Producers that will be audited.
void setBrokerURI(const decaf::net::URI &uri)
Sets the Broker URI that should be used when creating a new connection instance.
virtual void setExceptionListener(cms::ExceptionListener *listener)
Set an CMS ExceptionListener that will be set on eat connection once it has been created.
const std::string & getPassword() const
Gets the password that this factory will use when creating a new connection instance.
void setConsumerExpiryCheckEnabled(bool consumerExpiryCheckEnabled)
Configures whether this consumer will perform message expiration processing on all incoming messages.
static cms::Connection * createConnection(const std::string &uri, const std::string &username, const std::string &password, const std::string &clientId="")
Creates a connection with the specified user identity.
long long getConsumerFailoverRedeliveryWaitPeriod() const
Gets the delay period for a consumer redelivery.
void setOptimizeAcknowledge(bool optimizeAcknowledge)
Sets if Consumers are configured to use Optimized Acknowledge by default.
const decaf::net::URI & getBrokerURI() const
Gets the Broker URI that this factory will use when creating a new connection instance.
bool isAlwaysSyncSend() const
Gets if the Connection should always send things Synchronously.
void setCheckForDuplicates(bool checkForDuplicates)
Gets the value of the configured Duplicate Message detection feature.
void setAlwaysSessionAsync(bool alwaysSessionAsync)
If this flag is not set 'true' then a separate thread is not used for dispatching messages for each S...
unsigned int getCloseTimeout() const
Gets the assigned close timeout for this Connector.
void setClientId(const std::string &clientId)
Sets the Client Id.
void setPrefetchPolicy(PrefetchPolicy *policy)
Sets the PrefetchPolicy instance that this factory should use when it creates new Connection instance...
static const std::string DEFAULT_URI
Definition ActiveMQConnectionFactory.h:44
virtual cms::Connection * createConnection(const std::string &username, const std::string &password, const std::string &clientId)
Creates a connection with the specified user identity.
void setConnectResponseTimeout(unsigned int connectResponseTimeout)
Sets the connect response timeout to use when sending Message objects, this will protect clients usin...
void setExclusiveConsumer(bool exclusiveConsumer)
Enables or disables whether or not queue consumers should be exclusive or not for example to preserve...
void setWatchTopicAdvisories(bool value)
Sets whether Connection's created by this factory will listen for advisory messages regarding tempora...
void setNonBlockingRedelivery(bool nonBlockingRedelivery)
When true a MessageConsumer will not stop Message delivery before re-delivering Messages from a rolle...
void setCompressionLevel(int value)
Sets the Compression level used when Message body compression is enabled, a value of -1 causes the Co...
bool isUseRetroactiveConsumer() const
Should all created consumers be retroactive.
virtual ActiveMQConnection * createActiveMQConnection(const Pointer< transport::Transport > &transport, const Pointer< decaf::util::Properties > &properties)
Create a new ActiveMQConnection instnace using the provided Transport and Properties.
void setUseRetroactiveConsumer(bool useRetroactiveConsumer)
Sets whether or not retroactive consumers are enabled.
int getAuditDepth() const
Get the audit depth for Messages for consumers when using a fault tolerant transport.
bool isNonBlockingRedelivery() const
Returns true if non-blocking redelivery of Messages is configured for Consumers that are rolled back ...
void setOptimizeAcknowledgeTimeOut(long long optimizeAcknowledgeTimeOut)
The max time in milliseconds between optimized ack batches.
bool isAlwaysSessionAsync() const
Returns the current value of the always session async option.
virtual cms::Connection * createConnection()
Creates a connection with the default user identity.
int getCompressionLevel() const
Gets the currently configured Compression level for Message bodies.
virtual cms::Connection * createConnection(const std::string &username, const std::string &password)
Creates a connection with the specified user identity.
bool isTransactedIndividualAck() const
when true, submit individual transacted acks immediately rather than with transaction completion.
long long getOptimizeAcknowledgeTimeOut() const
Gets the time between optimized ack batches in milliseconds.
unsigned int getSendTimeout() const
Gets the assigned send timeout for this Connector.
ActiveMQConnectionFactory(const std::string &uri, const std::string &username="", const std::string &password="")
Constructor.
Concrete connection used for all connectors to the ActiveMQ broker.
Definition ActiveMQConnection.h:62
Interface for a Policy object that controls message Prefetching on various destination types in Activ...
Definition PrefetchPolicy.h:34
Interface for a RedeliveryPolicy object that controls how message Redelivery is handled in ActiveMQ-C...
Definition RedeliveryPolicy.h:34
Defines the interface for a factory that creates connection objects, the Connection objects returned ...
Definition ConnectionFactory.h:41
The client's connection to its provider.
Definition Connection.h:70
If a CMS provider detects a serious problem, it notifies the client application through an ExceptionL...
Definition ExceptionListener.h:37
Provides an interface for clients to transform cms::Message objects inside the CMS MessageProducer an...
Definition MessageTransformer.h:37
Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the defa...
Definition Pointer.h:53
This class represents an instance of a URI as defined by RFC 2396.
Definition URI.h:37
Definition ActiveMQTempDestination.h:29
Definition AbstractTransportFactory.h:30
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition CachedConsumer.h:24