/* Copyright 2013 Nationale-Nederlanden Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package nl.nn.adapterframework.jms; /** * A true multi-threaded {@link nl.nn.adapterframework.core.IPullingListener Listener}-class. * <br/> * * <p><b>Configuration:</b> * <table border="1"> * <tr><th>attributes</th><th>description</th><th>default</th></tr> * <tr><td>className</td><td>nl.nn.adapterframework.jms.JmsListener</td><td> </td></tr> * <tr><td>{@link #setName(String) name}</td> <td>name of the listener</td><td> </td></tr> * <tr><td>{@link #setDestinationName(String) destinationName}</td><td>name of the JMS destination (queue or topic) to use</td><td> </td></tr> * <tr><td>{@link #setDestinationType(String) destinationType}</td><td>either <code>QUEUE</code> or <code>TOPIC</code></td><td><code>QUEUE</code></td></tr> * <tr><td>{@link #setTransacted(boolean) transacted}</td><td>when true, the processing joins a transaction set up by the Pipeline or Receiver</td><td>false</td></tr> * <tr><td>{@link #setJmsTransacted(boolean) jmsTransacted}</td><td>when true, sessions are explicitly committed (exit-state equals commitOnState) or rolled-back (other exit-states) </td><td>false</td></tr> * <tr><td>{@link #setCommitOnState(String) commitOnState}</td><td> </td><td>"success"</td></tr> * <tr><td>{@link #setAcknowledgeMode(String) acknowledgeMode}</td><td>"auto", "dups" or "client"</td><td>"auto"</td></tr> * <tr><td>{@link #setPersistent(boolean) persistent}</td><td> </td><td> </td></tr> * <tr><td>{@link #setTimeOut(long) timeOut}</td><td>receiver timeout, in milliseconds</td><td>3000 [ms]</td></tr> * <tr><td>{@link #setUseReplyTo(boolean) useReplyTo}</td><td> </td><td>true</td></tr> * <tr><td>{@link #setReplyMessageTimeToLive(long) replyMessageTimeToLive}</td><td>time that replymessage will live</td><td>0 [ms]</td></tr> * <tr><td>{@link #setReplyMessageType(String) replyMessageType}</td><td>value of the JMSType field of the reply message</td><td>not set by application</td></tr> * <tr><td>{@link #setReplyDeliveryMode(String) replyDeliveryMode}</td><td>controls mode that reply messages are sent with: either 'persistent' or 'non_persistent'</td><td>not set by application</td></tr> * <tr><td>{@link #setReplyPriority(int) replyPriority}</td><td>sets the priority that is used to deliver the reply message. ranges from 0 to 9. Defaults to -1, meaning not set. Effectively the default priority is set by Jms to 4</td><td> </td></tr> * <tr><td>{@link #setJmsRealm(String) jmsRealm}</td><td> </td><td> </td></tr> * <tr><td>{@link #setForceMQCompliancy(String) forceMQCompliancy}</td><td>Possible values: 'MQ' or 'JMS'. Setting to 'MQ' informs the MQ-server that the replyto queue is not JMS compliant.</td><td>JMS</td></tr> * <tr><td>{@link #setForceMessageIdAsCorrelationId(boolean) forceMessageIdAsCorrelationId}</td><td> * forces that the CorrelationId that is received is ignored and replaced by the messageId that is received. Use this to create a new, globally unique correlationId to be used downstream. It also * forces that not the Correlation ID of the received message is used in a reply as CorrelationId, but the MessageId.</td><td>false</td></tr> * </table> *</p><p><b>Using transactions</b><br/> * Since version 4.1, Ibis supports distributed transactions using the XA-protocol. This feature is controlled by the * {@link #setTransacted(boolean) transacted} attribute. If this is set to <code>true</code>, received messages are * committed or rolled back, possibly together with other actions, by the receiver or the pipeline. * In case of a failure, all actions within the transaction are rolled back. * *</p><p><b>Using jmsTransacted and acknowledgement</b><br/> * If jmsTransacted is set <code>true</code>: it should ensure that a message is received and processed on a both or nothing basis. * IBIS will commit the the message, otherwise perform rollback. However using jmsTransacted, IBIS does not bring transactions within * the adapters under transaction control, compromising the idea of atomic transactions. In the roll-back situation messages sent to * other destinations within the Pipeline are NOT rolled back if jmsTransacted is set <code>true</code>! In the failure situation the * message is therefore completely processed, and the roll back does not mean that the processing is rolled back! To obtain the correct * (transactional) behaviour, {@link #setTransacted(boolean) transacted} should be used instead of {@link #setJmsTransacted(boolean) * listener.transacted}. *<p> * Setting {@link #setAcknowledgeMode(String) listener.acknowledgeMode} to "auto" means that messages are allways acknowledged (removed from * the queue, regardless of what the status of the Adapter is. "client" means that the message will only be removed from the queue * when the state of the Adapter equals the defined state for committing (specified by {@link #setCommitOnState(String) listener.commitOnState}). * The "dups" mode instructs the session to lazily acknowledge the delivery of the messages. This is likely to result in the * delivery of duplicate messages if JMS fails. It should be used by consumers who are tolerant in processing duplicate messages. * In cases where the client is tolerant of duplicate messages, some enhancement in performance can be achieved using this mode, * since a session has lower overhead in trying to prevent duplicate messages. * </p> * <p>The setting for {@link #setAcknowledgeMode(String) listener.acknowledgeMode} will only be processed if * the setting for {@link #setTransacted(boolean) listener.transacted} as well as for * {@link #setJmsTransacted(boolean) listener.jmsTransacted} is false.</p> * * <p>If {@link #setUseReplyTo(boolean) useReplyTo} is set and a replyTo-destination is * specified in the message, the JmsListener sends the result of the processing * in the pipeline to this destination. Otherwise the result is sent using the (optionally) * specified {@link #setSender(ISender) Sender}, that in turn sends the message to * whatever it is configured to.</p> * * <p><b>Notice:</b> the JmsListener is ONLY capable of processing * <code>javax.jms.TextMessage</code>s <br/><br/> * </p> * @author Gerrit van Brakel * @since 4.0.1, since 4.8 as 'switch'-class */ public class JmsListener extends PushingJmsListener { }