List of usage examples for javax.jms DeliveryMode PERSISTENT
int PERSISTENT
To view the source code for javax.jms DeliveryMode PERSISTENT.
Click Source Link
From source file:net.timewalker.ffmq4.local.destination.LocalQueue.java
@Override public boolean putLocked(AbstractMessage message, LocalSession session, MessageLockSet locks) throws JMSException { checkNotClosed();/*w w w .ja va 2 s. c om*/ checkTransactionLock(); // Consistency check if (!message.isInternalCopy()) throw new FFMQException("Message instance is not an FFMQ internal copy !", "CONSISTENCY_ERROR"); // Dispatch message to the adequate store MessageStore targetStore; if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) { // Use volatile store if possible, otherwise fallback to persistent store targetStore = volatileStore != null ? volatileStore : persistentStore; } else targetStore = persistentStore; if (targetStore == null) throw new FFMQException("Queue does not support this delivery mode : " + (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT ? "DeliveryMode.NON_PERSISTENT" : "DeliveryMode.PERSISTENT"), "INVALID_DELIVERY_MODE"); int newHandle; synchronized (storeLock) { newHandle = targetStore.store(message); if (newHandle == -1) { // No space left for this message in the target store if (targetStore == volatileStore && persistentStore != null && queueDef.isOverflowToPersistent()) { // Fallback to persistent store if possible targetStore = persistentStore; newHandle = targetStore.store(message); } // Cannot store the message anywhere if (newHandle == -1) throw new DataStoreFullException("Cannot store message : queue is full : " + getName()); } targetStore.lock(newHandle); locks.add(newHandle, targetStore.getDeliveryMode(), this, message); } if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT && requiresTransactionalUpdate()) { pendingChanges = true; return true; } else return false; }
From source file:net.timewalker.ffmq4.local.destination.LocalQueue.java
/** * Commit get operations on this queue (messages are removed) * @return true if a store commit is required to ensure data safety */// w ww . j a v a 2s. c o m public boolean remove(LocalSession localSession, TransactionItem[] items) throws JMSException { checkNotClosed(); checkTransactionLock(); int volatileCommitted = 0; int persistentCommitted = 0; synchronized (storeLock) { for (int n = 0; n < items.length; n++) { TransactionItem transactionItem = items[n]; if (transactionItem.getDestination() != this) continue; if (traceEnabled) log.trace(localSession + " COMMIT " + transactionItem.getMessageId()); // Delete message from store if (transactionItem.getDeliveryMode() == DeliveryMode.PERSISTENT) { persistentStore.delete(transactionItem.getHandle()); persistentCommitted++; } else { volatileStore.delete(transactionItem.getHandle()); volatileCommitted++; } } } acknowledgedGetCount.addAndGet(volatileCommitted + persistentCommitted); if (persistentCommitted > 0 && requiresTransactionalUpdate()) { pendingChanges = true; return true; } else return false; }
From source file:net.timewalker.ffmq4.local.destination.LocalQueue.java
/** * Rollback get operations on this queue (messages are unlocked).. * Consumers are notified of rollbacked messages availability * @return true if a commit is required to ensure data safety *///w w w . j a v a 2s.co m public boolean redeliverLocked(TransactionItem[] items, MessageLockSet locks) throws JMSException { checkNotClosed(); checkTransactionLock(); int volatileRollbacked = 0; int persistentRollbacked = 0; synchronized (storeLock) { for (int n = 0; n < items.length; n++) { TransactionItem transactionItem = items[n]; if (transactionItem.getDestination() != this) continue; // Not for us MessageStore store = transactionItem.getDeliveryMode() == DeliveryMode.PERSISTENT ? persistentStore : volatileStore; int handle = transactionItem.getHandle(); // Retrieve message content AbstractMessage msg = store.retrieve(handle); // Update redelivered flag both in memory and message store msg.setJMSRedelivered(true); handle = store.replace(handle, msg); if (redeliveryDelay > 0) { // Keep the message locked so it cannot be re-consumed immediately // and schedule message unlock after redeliveryDelay milliseconds redeliveryTimer.schedule(new RedeliveryTask(msg, store, handle), redeliveryDelay); } else { // Store lock for later release locks.add(handle, store.getDeliveryMode(), this, msg); } if (transactionItem.getDeliveryMode() == DeliveryMode.PERSISTENT) persistentRollbacked++; else volatileRollbacked++; } } rollbackedGetCount.addAndGet(volatileRollbacked + persistentRollbacked); if (persistentRollbacked > 0 && requiresTransactionalUpdate()) { pendingChanges = true; return true; } else return false; }
From source file:net.timewalker.ffmq4.local.destination.LocalTopic.java
@Override public boolean putLocked(AbstractMessage srcMessage, LocalSession session, MessageLockSet locks) throws JMSException { checkNotClosed();/*from w ww .jav a 2 s.c om*/ checkTransactionLock(); // Check delivery mode if (!topicDef.supportDeliveryMode(srcMessage.getJMSDeliveryMode())) throw new FFMQException("Topic does not support this delivery mode : " + (srcMessage.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT ? "DeliveryMode.NON_PERSISTENT" : "DeliveryMode.PERSISTENT"), "INVALID_DELIVERY_MODE"); sentToTopicCount.incrementAndGet(); String connectionID = session.getConnection().getId(); CopyOnWriteList<LocalTopicSubscription> subscriptionsSnapshot; synchronized (subscriptionMap) { if (subscriptions.isEmpty()) return false; subscriptionsSnapshot = subscriptions.fastCopy(); } boolean commitRequired = false; for (int i = 0; i < subscriptionsSnapshot.size(); i++) { LocalTopicSubscription subscription = subscriptionsSnapshot.get(i); // No-local filtering if (subscription.getNoLocal() && subscription.getConnectionID().equals(connectionID)) continue; try { // Message selector filtering MessageSelector selector = subscription.getMessageSelector(); if (selector != null) { srcMessage.ensureDeserializationLevel(MessageSerializationLevel.ALL_HEADERS); if (!selector.matches(srcMessage)) continue; } LocalQueue subscriberQueue = subscription.getLocalQueue(); // Only use transactional mode for fail-safe durable subscriptions if (subscriberQueue.requiresTransactionalUpdate() && subscription.isDurable()) { if (committables.add(subscriberQueue)) subscriberQueue.openTransaction(); if (!subscriberQueue.putLocked(srcMessage, session, locks)) if (srcMessage.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) throw new IllegalStateException("Should require a commit"); pendingChanges = true; commitRequired = true; } else { if (subscriberQueue.putLocked(srcMessage, session, locks)) throw new IllegalStateException("Should not require a commit"); } dispatchedFromTopicCount.incrementAndGet(); } catch (DataStoreFullException e) { processPutError(subscription.getSubscriberId(), e, getDefinition().getSubscriberOverflowPolicy()); } catch (JMSException e) { processPutError(subscription.getSubscriberId(), e, getDefinition().getSubscriberFailurePolicy()); } } return commitRequired; }
From source file:nl.nn.adapterframework.extensions.fxf.FxfSender.java
public String sendMessage(String correlationID, String message, ParameterResolutionContext prc) throws SenderException, TimeOutException { String action = "put"; String transfername = getTransfername(); String filename = message;//from w w w . j av a2s.c o m String command = getScript() + " " + action + " " + transfername + " " + filename; if (atLeastVersion2) { int timeout = getTimeout(); command = command + " " + timeout; } String remoteFilename = null; if (remoteFilenameParam != null && prc != null) { try { remoteFilename = (String) prc.getValues(paramList).getParameterValue(0).getValue(); command += " " + remoteFilename; } catch (ParameterException e) { throw new SenderException("Could not resolve remote filename", e); } } log.debug(getLogPrefix() + "sending local file [" + message + "] by executing command [" + command + "]"); String transporthandle = ProcessUtil.executeCommand(command, getTimeout() * 2); log.debug(getLogPrefix() + "output of command [" + transporthandle + "]"); if (transporthandle != null) { transporthandle = transporthandle.trim(); } // delete file or move it to processed directory if (isDelete() || StringUtils.isNotEmpty(getProcessedDirectory())) { File f = new File(message); try { log.debug(getLogPrefix() + "moving or deleteing file [" + message + "]"); FileUtils.moveFileAfterProcessing(f, getProcessedDirectory(), isDelete(), isOverwrite(), getNumberOfBackups()); } catch (Exception e) { throw new SenderException("Could not move file [" + message + "]", e); } } if (atLeastVersion2) { String commitMsg = FxfUtil.makeProcessedPutFileMessage(transporthandle); Session s = null; MessageProducer mp = null; try { s = createSession(); mp = getMessageProducer(s, getDestination()); // create message Message msg = createTextMessage(s, correlationID, commitMsg); mp.setDeliveryMode(DeliveryMode.PERSISTENT); // send message send(mp, msg); if (log.isDebugEnabled()) { log.debug(getLogPrefix() + "sent message [" + message + "] to [" + getDestinationName() + "] " + "msgID [" + msg.getJMSMessageID() + "]"); ; } else { if (log.isInfoEnabled()) { log.info(getLogPrefix() + "sent message to [" + getDestinationName() + "] " + "msgID [" + msg.getJMSMessageID() + "]"); ; } } } catch (Throwable e) { throw new SenderException(e); } finally { if (mp != null) { try { mp.close(); } catch (JMSException e) { log.warn(getLogPrefix() + "got exception closing message producer", e); } } closeSession(s); } } return transporthandle; }
From source file:nl.nn.adapterframework.extensions.ifsa.jms.PullingIfsaProviderListener.java
/** * Extracts ID-string from message obtained from {@link #getRawMessage(Map)}. * Puts also the following parameters in the threadContext: * <ul>/* w w w.ja v a2 s. c o m*/ * <li>id</li> * <li>cid</li> * <li>timestamp</li> * <li>replyTo</li> * <li>messageText</li> * <li>fullIfsaServiceName</li> * <li>ifsaServiceName</li> * <li>ifsaGroup</li> * <li>ifsaOccurrence</li> * <li>ifsaVersion</li> * </ul> * @return ID-string of message for adapter. */ public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException { IFSAMessage message = null; if (rawMessage instanceof IMessageWrapper) { return getIdFromWrapper((IMessageWrapper) rawMessage, threadContext); } try { message = (IFSAMessage) rawMessage; } catch (ClassCastException e) { log.error(getLogPrefix() + "message received was not of type IFSAMessage, but [" + rawMessage.getClass().getName() + "]", e); return null; } String mode = "unknown"; String id = "unset"; String cid = "unset"; Date tsSent = null; Destination replyTo = null; String messageText = null; String fullIfsaServiceName = null; IFSAServiceName requestedService = null; String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null; try { if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) { mode = "NON_PERSISTENT"; } else if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) { mode = "PERSISTENT"; } } catch (JMSException ignore) { } // -------------------------- // retrieve MessageID // -------------------------- try { id = message.getJMSMessageID(); } catch (JMSException ignore) { } // -------------------------- // retrieve CorrelationID // -------------------------- try { cid = message.getJMSCorrelationID(); if (cid == null) { cid = id; log.debug("Setting correlation ID to MessageId"); } } catch (JMSException ignore) { } // -------------------------- // retrieve TimeStamp // -------------------------- try { long lTimeStamp = message.getJMSTimestamp(); tsSent = new Date(lTimeStamp); } catch (JMSException ignore) { } // -------------------------- // retrieve ReplyTo address // -------------------------- try { replyTo = message.getJMSReplyTo(); } catch (JMSException ignore) { } // -------------------------- // retrieve message text // -------------------------- try { messageText = ((TextMessage) message).getText(); } catch (Throwable ignore) { } // -------------------------- // retrieve ifsaServiceDestination // -------------------------- try { fullIfsaServiceName = message.getServiceString(); requestedService = message.getService(); ifsaServiceName = requestedService.getServiceName(); ifsaGroup = requestedService.getServiceGroup(); ifsaOccurrence = requestedService.getServiceOccurance(); ifsaVersion = requestedService.getServiceVersion(); } catch (JMSException e) { log.error(getLogPrefix() + "got error getting serviceparameter", e); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n JMSMessageID=[" + id + "] \n JMSCorrelationID=[" + cid + "] \n ifsaServiceName=[" + ifsaServiceName + "] \n ifsaGroup=[" + ifsaGroup + "] \n ifsaOccurrence=[" + ifsaOccurrence + "] \n ifsaVersion=[" + ifsaVersion + "] \n Timestamp Sent=[" + DateUtils.format(tsSent) + "] \n ReplyTo=[" + ((replyTo == null) ? "none" : replyTo.toString()) + "] \n MessageHeaders=[" + displayHeaders(message) + "\n" + "] \n Message=[" + message.toString() + "\n]"); } PipeLineSessionBase.setListenerParameters(threadContext, id, cid, null, tsSent); threadContext.put("timestamp", tsSent); threadContext.put("replyTo", ((replyTo == null) ? "none" : replyTo.toString())); threadContext.put("messageText", messageText); threadContext.put("fullIfsaServiceName", fullIfsaServiceName); threadContext.put("ifsaServiceName", ifsaServiceName); threadContext.put("ifsaGroup", ifsaGroup); threadContext.put("ifsaOccurrence", ifsaOccurrence); threadContext.put("ifsaVersion", ifsaVersion); Map udz = (Map) message.getIncomingUDZObject(); if (udz != null) { String contextDump = "ifsaUDZ:"; for (Iterator it = udz.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); String value = (String) udz.get(key); contextDump = contextDump + "\n " + key + "=[" + value + "]"; threadContext.put(key, value); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + contextDump); } } return id; }
From source file:nl.nn.adapterframework.extensions.ifsa.jms.PushingIfsaProviderListener.java
/** * Extracts ID-string from message obtained from {@link #getRawMessage(Map)}. * Puts also the following parameters in the threadContext: * <ul>// w w w.ja v a 2 s .co m * <li>id</li> * <li>cid</li> * <li>timestamp</li> * <li>replyTo</li> * <li>messageText</li> * <li>fullIfsaServiceName</li> * <li>ifsaServiceName</li> * <li>ifsaGroup</li> * <li>ifsaOccurrence</li> * <li>ifsaVersion</li> * <li>ifsaBifName</li> * <li>ifsaBtcData</li> * </ul> * @return ID-string of message for adapter. */ public String getIdFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException { IFSAMessage message = null; if (rawMessage instanceof IMessageWrapper) { return getIdFromWrapper((IMessageWrapper) rawMessage, threadContext); } try { message = (IFSAMessage) rawMessage; } catch (ClassCastException e) { log.error(getLogPrefix() + "message received was not of type IFSAMessage, but [" + rawMessage.getClass().getName() + "]", e); return null; } String mode = "unknown"; String id = "unset"; String cid = "unset"; Date tsSent = null; Destination replyTo = null; String messageText = null; String fullIfsaServiceName = null; IFSAServiceName requestedService = null; String ifsaServiceName = null, ifsaGroup = null, ifsaOccurrence = null, ifsaVersion = null; try { if (message.getJMSDeliveryMode() == DeliveryMode.NON_PERSISTENT) { mode = "NON_PERSISTENT"; } else if (message.getJMSDeliveryMode() == DeliveryMode.PERSISTENT) { mode = "PERSISTENT"; } } catch (JMSException ignore) { } // -------------------------- // retrieve MessageID // -------------------------- try { id = message.getJMSMessageID(); } catch (JMSException ignore) { } // -------------------------- // retrieve CorrelationID // -------------------------- try { cid = message.getJMSCorrelationID(); } catch (JMSException ignore) { } // -------------------------- // retrieve TimeStamp // -------------------------- try { long lTimeStamp = message.getJMSTimestamp(); tsSent = new Date(lTimeStamp); } catch (JMSException ignore) { } // -------------------------- // retrieve ReplyTo address // -------------------------- try { replyTo = message.getJMSReplyTo(); } catch (JMSException ignore) { } // -------------------------- // retrieve message text // -------------------------- try { messageText = ((TextMessage) message).getText(); } catch (Throwable ignore) { } // -------------------------- // retrieve ifsaServiceDestination // -------------------------- try { fullIfsaServiceName = message.getServiceString(); requestedService = message.getService(); ifsaServiceName = requestedService.getServiceName(); ifsaGroup = requestedService.getServiceGroup(); ifsaOccurrence = requestedService.getServiceOccurance(); ifsaVersion = requestedService.getServiceVersion(); } catch (JMSException e) { log.error(getLogPrefix() + "got error getting serviceparameter", e); } String BIFname = null; try { BIFname = message.getBifName(); if (StringUtils.isNotEmpty(BIFname)) { threadContext.put(THREAD_CONTEXT_BIFNAME_KEY, BIFname); } } catch (JMSException e) { log.error(getLogPrefix() + "got error getting BIFname", e); } byte btcData[] = null; try { btcData = message.getBtcData(); } catch (JMSException e) { log.error(getLogPrefix() + "got error getting btcData", e); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + "got message for [" + fullIfsaServiceName + "] with JMSDeliveryMode=[" + mode + "] \n JMSMessageID=[" + id + "] \n JMSCorrelationID=[" + cid + "] \n BIFname=[" + BIFname + "] \n ifsaServiceName=[" + ifsaServiceName + "] \n ifsaGroup=[" + ifsaGroup + "] \n ifsaOccurrence=[" + ifsaOccurrence + "] \n ifsaVersion=[" + ifsaVersion + "] \n Timestamp Sent=[" + DateUtils.format(tsSent) + "] \n ReplyTo=[" + ((replyTo == null) ? "none" : replyTo.toString()) + "] \n MessageHeaders=[" + displayHeaders(message) + "\n" // + "] \n btcData=["+ btcData + "] \n Message=[" + message.toString() + "\n]"); } // if (cid == null) { // if (StringUtils.isNotEmpty(BIFname)) { // cid = BIFname; // if (log.isDebugEnabled()) log.debug("Setting correlation ID to BIFname ["+cid+"]"); // } else { // cid = id; // if (log.isDebugEnabled()) log.debug("Setting correlation ID to MessageId ["+cid+"]"); // } // } PipeLineSessionBase.setListenerParameters(threadContext, id, BIFname, null, tsSent); threadContext.put("timestamp", tsSent); threadContext.put("replyTo", ((replyTo == null) ? "none" : replyTo.toString())); threadContext.put("messageText", messageText); threadContext.put("fullIfsaServiceName", fullIfsaServiceName); threadContext.put("ifsaServiceName", ifsaServiceName); threadContext.put("ifsaGroup", ifsaGroup); threadContext.put("ifsaOccurrence", ifsaOccurrence); threadContext.put("ifsaVersion", ifsaVersion); threadContext.put("ifsaBifName", BIFname); threadContext.put("ifsaBtcData", btcData); Map udz = (Map) message.getIncomingUDZObject(); if (udz != null) { String contextDump = "ifsaUDZ:"; for (Iterator it = udz.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); String value = (String) udz.get(key); contextDump = contextDump + "\n " + key + "=[" + value + "]"; threadContext.put(key, value); } if (log.isDebugEnabled()) { log.debug(getLogPrefix() + contextDump); } } return BIFname; }
From source file:nl.nn.adapterframework.extensions.tibco.SendTibcoMessage.java
public String doPipeWithTimeoutGuarded(Object input, IPipeLineSession session) throws PipeRunException { Connection connection = null; Session jSession = null;//from ww w.j a va2 s. c om MessageProducer msgProducer = null; Destination destination = null; String url_work; String authAlias_work; String userName_work; String password_work; String queueName_work; String messageProtocol_work; int replyTimeout_work; String soapAction_work; String result = null; ParameterValueList pvl = null; if (getParameterList() != null) { ParameterResolutionContext prc = new ParameterResolutionContext((String) input, session); try { pvl = prc.getValues(getParameterList()); } catch (ParameterException e) { throw new PipeRunException(this, getLogPrefix(session) + "exception on extracting parameters", e); } } url_work = getParameterValue(pvl, "url"); if (url_work == null) { url_work = getUrl(); } authAlias_work = getParameterValue(pvl, "authAlias"); if (authAlias_work == null) { authAlias_work = getAuthAlias(); } userName_work = getParameterValue(pvl, "userName"); if (userName_work == null) { userName_work = getUserName(); } password_work = getParameterValue(pvl, "password"); if (password_work == null) { password_work = getPassword(); } queueName_work = getParameterValue(pvl, "queueName"); if (queueName_work == null) { queueName_work = getQueueName(); } messageProtocol_work = getParameterValue(pvl, "messageProtocol"); if (messageProtocol_work == null) { messageProtocol_work = getMessageProtocol(); } String replyTimeout_work_str = getParameterValue(pvl, "replyTimeout"); if (replyTimeout_work_str == null) { replyTimeout_work = getReplyTimeout(); } else { replyTimeout_work = Integer.parseInt(replyTimeout_work_str); } soapAction_work = getParameterValue(pvl, "soapAction"); if (soapAction_work == null) soapAction_work = getSoapAction(); if (StringUtils.isEmpty(soapAction_work) && !StringUtils.isEmpty(queueName_work)) { String[] q = queueName_work.split("\\."); if (q.length > 0) { if (q[0].equalsIgnoreCase("P2P") && q.length >= 4) { soapAction_work = q[3]; } else if (q[0].equalsIgnoreCase("ESB") && q.length == 8) { soapAction_work = q[5] + "_" + q[6]; } else if (q[0].equalsIgnoreCase("ESB") && q.length > 8) { soapAction_work = q[6] + "_" + q[7]; } } } if (StringUtils.isEmpty(soapAction_work)) { log.debug(getLogPrefix(session) + "deriving default soapAction"); try { URL resource = ClassUtils.getResourceURL(this, "/xml/xsl/esb/soapAction.xsl"); TransformerPool tp = new TransformerPool(resource, true); soapAction_work = tp.transform(input.toString(), null); } catch (Exception e) { log.error(getLogPrefix(session) + "failed to execute soapAction.xsl"); } } if (messageProtocol_work == null) { throw new PipeRunException(this, getLogPrefix(session) + "messageProtocol must be set"); } if (!messageProtocol_work.equalsIgnoreCase(REQUEST_REPLY) && !messageProtocol_work.equalsIgnoreCase(FIRE_AND_FORGET)) { throw new PipeRunException(this, getLogPrefix(session) + "illegal value for messageProtocol [" + messageProtocol_work + "], must be '" + REQUEST_REPLY + "' or '" + FIRE_AND_FORGET + "'"); } CredentialFactory cf = new CredentialFactory(authAlias_work, userName_work, password_work); try { TibjmsAdmin admin; try { admin = TibcoUtils.getActiveServerAdmin(url_work, cf); } catch (TibjmsAdminException e) { log.debug(getLogPrefix(session) + "caught exception", e); admin = null; } if (admin != null) { QueueInfo queueInfo; try { queueInfo = admin.getQueue(queueName_work); } catch (Exception e) { throw new PipeRunException(this, getLogPrefix(session) + " exception on getting queue info", e); } if (queueInfo == null) { throw new PipeRunException(this, getLogPrefix(session) + " queue [" + queueName_work + "] does not exist"); } try { admin.close(); } catch (TibjmsAdminException e) { log.warn(getLogPrefix(session) + "exception on closing Tibjms Admin", e); } } ConnectionFactory factory = new com.tibco.tibjms.TibjmsConnectionFactory(url_work); connection = factory.createConnection(cf.getUsername(), cf.getPassword()); jSession = connection.createSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); destination = jSession.createQueue(queueName_work); msgProducer = jSession.createProducer(destination); TextMessage msg = jSession.createTextMessage(); msg.setText(input.toString()); Destination replyQueue = null; if (messageProtocol_work.equalsIgnoreCase(REQUEST_REPLY)) { replyQueue = jSession.createTemporaryQueue(); msg.setJMSReplyTo(replyQueue); msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); msgProducer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); msgProducer.setTimeToLive(replyTimeout_work); } else { msg.setJMSDeliveryMode(DeliveryMode.PERSISTENT); msgProducer.setDeliveryMode(DeliveryMode.PERSISTENT); } if (StringUtils.isNotEmpty(soapAction_work)) { log.debug( getLogPrefix(session) + "setting [SoapAction] property to value [" + soapAction_work + "]"); msg.setStringProperty("SoapAction", soapAction_work); } msgProducer.send(msg); if (log.isDebugEnabled()) { log.debug(getLogPrefix(session) + "sent message [" + msg.getText() + "] " + "to [" + msgProducer.getDestination() + "] " + "msgID [" + msg.getJMSMessageID() + "] " + "correlationID [" + msg.getJMSCorrelationID() + "] " + "replyTo [" + msg.getJMSReplyTo() + "]"); } else { if (log.isInfoEnabled()) { log.info(getLogPrefix(session) + "sent message to [" + msgProducer.getDestination() + "] " + "msgID [" + msg.getJMSMessageID() + "] " + "correlationID [" + msg.getJMSCorrelationID() + "] " + "replyTo [" + msg.getJMSReplyTo() + "]"); } } if (messageProtocol_work.equalsIgnoreCase(REQUEST_REPLY)) { String replyCorrelationId = msg.getJMSMessageID(); MessageConsumer msgConsumer = jSession.createConsumer(replyQueue, "JMSCorrelationID='" + replyCorrelationId + "'"); log.debug(getLogPrefix(session) + "] start waiting for reply on [" + replyQueue + "] selector [" + replyCorrelationId + "] for [" + replyTimeout_work + "] ms"); try { connection.start(); Message rawReplyMsg = msgConsumer.receive(replyTimeout_work); if (rawReplyMsg == null) { throw new PipeRunException(this, getLogPrefix(session) + "did not receive reply on [" + replyQueue + "] replyCorrelationId [" + replyCorrelationId + "] within [" + replyTimeout_work + "] ms"); } TextMessage replyMsg = (TextMessage) rawReplyMsg; result = replyMsg.getText(); } finally { } } else { result = msg.getJMSMessageID(); } } catch (JMSException e) { throw new PipeRunException(this, getLogPrefix(session) + " exception on sending message to Tibco queue", e); } finally { if (connection != null) { try { connection.close(); } catch (JMSException e) { log.warn(getLogPrefix(session) + "exception on closing connection", e); } } } return result; }
From source file:nl.nn.adapterframework.jms.JMSFacade.java
public static int stringToDeliveryMode(String mode) { if (MODE_PERSISTENT.equalsIgnoreCase(mode)) { return DeliveryMode.PERSISTENT; }/* www . ja v a2s. co m*/ if (MODE_NON_PERSISTENT.equalsIgnoreCase(mode)) { return DeliveryMode.NON_PERSISTENT; } return 0; }
From source file:nl.nn.adapterframework.jms.JMSFacade.java
public static String deliveryModeToString(int mode) { if (mode == 0) { return "not set by application"; }/* w w w . j a v a 2 s .c o m*/ if (mode == DeliveryMode.PERSISTENT) { return MODE_PERSISTENT; } if (mode == DeliveryMode.NON_PERSISTENT) { return MODE_NON_PERSISTENT; } return "unknown delivery mode [" + mode + "]"; }