What are we doing?
We are using mq-jms-spring-boot-starter and #JMSListener-annotation to implement an Message-Listener for a IBM MQ queue (lets call this: QueueA).
When an exception is thrown within the function annotated with #JMSListener the current message is automatically re-queued in the connected QueueA. At the MQ-Server we configured a retry-count (3 retries) and after 3 un-successful retries the message is send to a backout-queue (QueueA-BACKOUT).
What's our question?
Basically we want to use the automatic mechanism provided by #JMSListener to re-queue a message but with a delay before doing so.
For testing purposes we use ActiveMQ. There we could easily configure an initialRedeliveryDelay/redeliveryDelay in the ConnectionFactory.
What is the equivalent way to configure something like this for IBM MQ (using the mentioned Spring Starter)?
(INFO: we did not implement an errorhandler for the listener yet, might this be the right place to do something like this? Or is there a simple configuration-style option to solve this?)
Related
I want a Java class (jms receiver) which always run in background and check for any message arrive in jms queue.How it can be possible? Please help.
What you want is a JMS MessageListener. Create your JMS client resources (e.g. connection/context, session, etc.) like normal and then invoke setMessageListener on your consumer passing in your implementation of the MessageListener interface. This is pretty basic JMS stuff so you can find more detailed tutorials online.
Can someone explain different ways of configuring message listener.
I know two ways:
Spring Jms Listener
EJB MDB way.
Are there any other ways (should be applicable to both IBM MQ and Active MQ)?
For the first question, your proposed ways are good ones with Camel JMS.
For the second question take a look at Java JMS mix messaging implementations
if you want to use the same client without changing anything you have to use AMQP ptotocol wich is designed for this.
here is 2 examples :
ActiveMQ AMQP with JMS transformer leveraging spring Integration
Unable to access ActiveMQ using JMS based code and amqp 1.0
I want my system to guarantee there is no data loss even if the system is shutting down.
What this mean is that the system must not miss the request message. So, I will change the way that accept http reqeust. Now, I am using http gateway/webservice gateway in spring integration. But, This isn't receive the message even if the system dies. So, I want to add the queue between the http client and the http receiver. So, I want to use a queue channel. Here is the question.
① I have to install other queue program such as activemq or rabbitmq and have to connect to the queue channel in spring integration?
② and which one is the best combination with spring integration? I heard that rabbit mq is the best one.
please give me a elaborate explanation. thanks.
First of all you description isn't clear...
If you don't want to lose messages from the QueueChannel use some Persistence MessageStore, like JdbcChannelMessageStore:
http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/system-management-chapter.html#message-store
From other side there are channel wrappers for the AMQP as well as for JMS:
http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/amqp.html#d4e5846
http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/jms.html#jms-channel
Which really provide the same persistence durability, fault tollerant options for your use-case.
Re. activemq VS rabbitmq. I can say by my own expiriance that the last one is better, by configuration, usage from Spring Integration (Spring AMQP is under the shell). And its performance is really better.
All other info you can find in the Internet.
I just recently started learning about spring-integration since I need to replace the a MDB(J2EE) application.
The application is composed of mostly MDB which does, splitting, aggregating and scheduling. Which, I think is the perfect criteria to use spring-integration.
I tried out some JMS examples and tried to deploy it but could not figure out how to use the jms-inbound-gateway to replace the MDB.
Is there a way to do this? Or is the only option is still to use MDB and calling the spring-integration service from the MDB's onMessage?
Use a message-driven-channel-adapter instead of an inbound gateway.
With Spring Integration, gateways are for two-way (request/reply) integraton; channel adapters are for one way integration; more like MDBs.
If you need to send some other JMS message downstream, use an outbound channel adapter later in the flow.
It's unusual to keep the MDBs, but you can do it if you really want to, and send a message to an integration flow.
//OVERVIEW//
I have a Java Swing Client that is pushing messages to a broker. For the producer, I am using the Spring SingleConnectionFactory:
org.springframework.jms.connection.SingleConnectionFactory
that is wrapped around an ActiveMQConnectionFactory:
org.apache.activemq.ActiveMQConnectionFactory
I am using the Spring JMSTemplate:
org.springframework.jms.core.JmsTemplate
to provide the mechanisms to send messages from the producer to the broker.
// PROBLEM //
Sometimes, the broker might go down, or the network might fail. When this happens, the only way I have been able to re-establish connection to the broker is to re-start the Swing application (producer) to re-initialize the components mentioned above.
Does anyone know how this might be done at run-time? Atempting to re-initialise beans at runtime sounds like a hack and I was wondering if there was a more elegant configuration option.
Thanks