Package com.github.ddth.queue.impl
Class RabbitMqQueueFactory<T extends RabbitMqQueue<ID,DATA>,ID,DATA>
- java.lang.Object
-
- com.github.ddth.queue.impl.AbstractQueueFactory<T,ID,DATA>
-
- com.github.ddth.queue.impl.RabbitMqQueueFactory<T,ID,DATA>
-
- All Implemented Interfaces:
IQueueFactory<ID,DATA>,AutoCloseable
- Direct Known Subclasses:
UniversalRabbitMqQueueFactory,UniversalRabbitMqQueueFactory
public abstract class RabbitMqQueueFactory<T extends RabbitMqQueue<ID,DATA>,ID,DATA> extends AbstractQueueFactory<T,ID,DATA>
Factory to createRabbitMqQueueinstances.- Since:
- 0.6.1
- Author:
- Thanh Ba Nguyen
-
-
Field Summary
Fields Modifier and Type Field Description static StringSPEC_FIELD_QUEUE_NAMEstatic StringSPEC_FIELD_URI
-
Constructor Summary
Constructors Constructor Description RabbitMqQueueFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddestroy()Destroy method.protected com.rabbitmq.client.ConnectionFactorygetDefaultConnectionFactory()If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).StringgetDefaultQueueName()Default name of RabbitMQ queue to send/receive messages, passed to all queues created by this factory.StringgetDefaultUri()Default RabbitMQ's connection URI (formatamqp://username:password@host:port/virtualHost), passed to all queues created by this factory.protected voidinitQueue(T queue, QueueSpec spec)Initialize a newly created queue instance.RabbitMqQueueFactory<T,ID,DATA>setDefaultConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory)If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).protected RabbitMqQueueFactory<T,ID,DATA>setDefaultConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory, boolean setMyOwnConnectionFactory)If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).RabbitMqQueueFactory<T,ID,DATA>setDefaultQueueName(String defaultQueueName)Default name of RabbitMQ queue to send/receive messages, passed to all queues created by this factory.RabbitMqQueueFactory<T,ID,DATA>setDefaultUri(String defaultUri)Default RabbitMQ's connection URI (formatamqp://username:password@host:port/virtualHost), passed to all queues created by this factory.-
Methods inherited from class com.github.ddth.queue.impl.AbstractQueueFactory
close, createAndInitQueue, createQueueInstance, getDefaultEphemeralDisabled, getDefaultEphemeralMaxSize, getDefaultMaxSize, getQueue, init, isDefaultEphemeralDisabled, setDefaultEphemeralDisabled, setDefaultEphemeralMaxSize, setDefaultMaxSize
-
-
-
-
Field Detail
-
SPEC_FIELD_URI
public static final String SPEC_FIELD_URI
- See Also:
- Constant Field Values
-
SPEC_FIELD_QUEUE_NAME
public static final String SPEC_FIELD_QUEUE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
getDefaultUri
public String getDefaultUri()
Default RabbitMQ's connection URI (formatamqp://username:password@host:port/virtualHost), passed to all queues created by this factory.- Returns:
-
setDefaultUri
public RabbitMqQueueFactory<T,ID,DATA> setDefaultUri(String defaultUri)
Default RabbitMQ's connection URI (formatamqp://username:password@host:port/virtualHost), passed to all queues created by this factory.- Parameters:
defaultUri-- Returns:
-
getDefaultQueueName
public String getDefaultQueueName()
Default name of RabbitMQ queue to send/receive messages, passed to all queues created by this factory.- Returns:
-
setDefaultQueueName
public RabbitMqQueueFactory<T,ID,DATA> setDefaultQueueName(String defaultQueueName)
Default name of RabbitMQ queue to send/receive messages, passed to all queues created by this factory.- Parameters:
defaultQueueName-- Returns:
-
getDefaultConnectionFactory
protected com.rabbitmq.client.ConnectionFactory getDefaultConnectionFactory()
If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).- Returns:
- Since:
- 0.7.1
-
setDefaultConnectionFactory
protected RabbitMqQueueFactory<T,ID,DATA> setDefaultConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory, boolean setMyOwnConnectionFactory)
If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).- Parameters:
connectionFactory-setMyOwnConnectionFactory-- Returns:
- Since:
- 0.7.1
-
setDefaultConnectionFactory
public RabbitMqQueueFactory<T,ID,DATA> setDefaultConnectionFactory(com.rabbitmq.client.ConnectionFactory connectionFactory)
If allRabbitMqQueueinstances are connecting to one RabbitMQ broker, it's a good idea to pre-create anConnectionFactoryinstance and share it amongstRabbitMqQueueinstances created from this factory by assigning it todefaultConnectionFactory(seesetDefaultConnectionFactory(ConnectionFactory)).- Parameters:
connectionFactory-- Returns:
- Since:
- 0.7.1
-
destroy
public void destroy()
Destroy method.- Overrides:
destroyin classAbstractQueueFactory<T extends RabbitMqQueue<ID,DATA>,ID,DATA>
-
initQueue
protected void initQueue(T queue, QueueSpec spec) throws Exception
Initialize a newly created queue instance.Called by
AbstractQueueFactory.createAndInitQueue(QueueSpec). Sub-class may override this method to implement its own business logic.- Overrides:
initQueuein classAbstractQueueFactory<T extends RabbitMqQueue<ID,DATA>,ID,DATA>- Throws:
Exception
-
-