EzyActiveMQ Configuration

Updated at 1685687685000

1. Configuration List

EzyActiveMQ provides a list of configurations in bellow table:

PropertyDefault ValueDescription
1activemq.urifailover://tcp://localhost:61616ActiveMQ uri
2activemq.usernamenullActiveMQ username
3activemq.passwordnullActiveMQ password
4activemq.max_thread_pool_size1000Max thread pool size
6activemq.producersnullList of ActiveMQ producers
5activemq.consumersnullList of ActiveMQ consumers
7activemq.topicsnullList of ActiveMQ topics

For every producer, EzyActiveMQ provides bellow properties:

PropertyDefault ValueDescription
1request_queue_name[producer name]-requestName of the request queue
2reply_queue_name[producer name]-replyName of the reply queue
3thread_pool_size1Thread pool size for reply message consumer
4capacity10000Capacity of the producer
5default_timeoutno timeoutDefault timeout of a rpc request in millisecond

For every consumer, EzyActiveMQ provides bellow properties:

PropertyDefault ValueDescription
1request_queue_name[consumer name]-requestName of the request queue
2reply_queue_name[consumer name]-replyName of the consumer's request queue of the producer
3thread_pool_size1Thread pool size for rquest message consumer

For every topic, EzyActiveMQ provides bellow properties:

PropertyDefault ValueDescription
1producernullProducer for the topic settings
2producer.enabletrue if producer is not nullEnable producer or not
3consumernullConsumer for the topic settings
4consumer.enabletrue if consumer is not nullEnable consumer or not

2. An Example

Let's we neen create a producer and a consumer named test and a topic named hello, you can put bellow configuration to your application.yaml file:

# for application.yaml
    test: default
    test: default
      producer: default
      consumer: default

Or for application.properties file:

# for application.properties

3. Configure for producer

You can configure for producer like this:

EzyActiveMQProxy proxy = EzyActiveMQProxy.builder()
    .mapTopicMessageType("hello", "hello", SumRequest.class)
EzyActiveRpcProducer producer = proxy.getRpcProducer("test");

4. Configure for consumer

You can configure for consumer like this:


5. Topic usage

You can get the topic like this:

EzyActiveTopic<SumRequest> sumTopic = proxy.getTopic("hello");

And use the topic to publish a message like this:

sumTopic.publish("hello", new SumRequest(a, b));

You also can add message consumer for the topic like this:

sumTopic.addConsumer("hello", message ->
    System.out.println("sum request: " + message)