List of usage examples for javax.jms DeliveryMode NON_PERSISTENT
int NON_PERSISTENT
To view the source code for javax.jms DeliveryMode NON_PERSISTENT.
Click Source Link
From source file:com.chinamobile.bcbsp.comm.ProducerTool.java
/** Run method of Thread. */ public final void run() { while (true) { while (this.idle) { if (this.completed) { return; }/*from w w w .jav a2 s . c o m*/ if (this.noMoreMessagesFlag) { this.superStepCounter++; this.noMoreMessagesFlag = false; // LOG.info("Test Progress: from " + (this.superStepCounter - 1) + // " to " + this.superStepCounter); } try { Thread.sleep(this.sleepTime); } catch (InterruptedException e) { LOG.error("[ProducerTool] to " + this.hostNameAndPort + " has been interrupted for ", e); return; } } if (this.hostNameAndPort == null) { LOG.error("Destination hostname is null."); return; } if (this.messageQueue == null) { LOG.error("Message queue for ProducerTool is null."); return; } this.messageCount = 0; this.connectTime = 0; this.sendTime = 0; while (true) { if (this.reconnectCount == ProducerTool.RECONNECTTHRESHOLD) { break; } try { if (this.newHostNameAndPort) { // Should create new connection. if (connection != null) { try { connection.close(); } catch (Throwable ignore) { LOG.warn("[ConsumerTool] run connection " + ignore); } } long start = System.currentTimeMillis(); /** Clock */ // Make the destination broker's url. this.url = "tcp://" + this.hostNameAndPort; // Create the connection. // ActiveMQConnectionFactory connectionFactory = new // ActiveMQConnectionFactory( // user, password, url); BSPActiveMQConnFactory connectionFactory = new BSPActiveMQConnFactoryImpl(); connectionFactory.activeMQConnFactoryMethod(url); connectionFactory.setCopyMessageOnSend(false); connection = connectionFactory.createConnection(); connection.start(); // Create the session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE); this.connectTime += (System.currentTimeMillis() - start); /* Clock */ this.newHostNameAndPort = false; start = System.currentTimeMillis(); /* Clock */ destination = session.createQueue(subject); // Create the producer. producer = session.createProducer(destination); if (persistent) { producer.setDeliveryMode(DeliveryMode.PERSISTENT); } else { producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT); } if (timeToLive != 0) { producer.setTimeToLive(timeToLive); } this.connectTime += (System.currentTimeMillis() - start); } // Start sending messages sendLoopOptimistic(session, producer); this.idle = true; break; } catch (Exception e) { this.reconnectCount++; if (this.reconnectCount == 1) { LOG.error("[ProducerTool] to " + this.hostNameAndPort + " caught: ", e); } LOG.info("[ProducerTool] to " + this.hostNameAndPort + " is reconnecting for " + this.reconnectCount + "th time."); LOG.info("---------------- Memory Info ------------------"); MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage memoryUsage = memoryMXBean.getHeapMemoryUsage(); long used = memoryUsage.getUsed(); long committed = memoryUsage.getCommitted(); LOG.info("[JVM Memory used] = " + used / MB_SIZE + "MB"); LOG.info("[JVM Memory committed] = " + committed / MB_SIZE + "MB"); LOG.info("-----------------------------------------------"); try { Thread.sleep(this.sleepTime); } catch (InterruptedException e1) { LOG.error("[ProducerTool] caught: ", e1); } } } LOG.info("[ProducerTool] to " + this.hostNameAndPort + " has sent " + this.messageCount + " messages totally! (with " + this.messageQueue.size() + " messages lost!)"); this.sender.addConnectTime(this.connectTime); /* Clock */ this.sender.addSendTime(this.sendTime); /* Clock */ if (this.reconnectCount == ProducerTool.RECONNECTTHRESHOLD) { LOG.info("[ProducerTool] to " + this.hostNameAndPort + " has reconnected for " + this.reconnectCount + " times but failed!"); this.isFailed = true; break; } } }
From source file:org.logicblaze.lingo.jms.JmsClientInterceptor.java
/** * Sets the delivery mode to be persistent or non-persistent. *//*from w w w . j a v a2s . co m*/ public void setPersistentDelivery(boolean persistent) { producerConfig.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); }
From source file:org.frameworkset.mq.RequestDispatcher.java
public void send(int destinationType, String destination_, boolean persistent, int priority, long timeToLive, Message message, JMSProperties properties) throws JMSException { LOG.debug("send message to " + destination_ + " assertStarted(),message=" + message); assertStarted();//from w ww. j ava 2 s . c o m MessageProducer producer = null; try { Destination destination = null; // destinationType = JMSConnectionFactory.evaluateDestinationType(destination_, destinationType); // destination_ = JMSConnectionFactory.evaluateDestination(destination_); // boolean isqueue = destinationType == MQUtil.TYPE_QUEUE; // if (isqueue) // { // LOG.debug("send message to " + destination_ // + " build QUEUE destination"); // destination = session.createQueue(destination_); // LOG.debug("send message to " + destination_ // + " build QUEUE destination end"); // } // else // { // LOG.debug("send message to " + destination_ // + " build Topic destination"); // destination = session.createTopic(destination_); // LOG.debug("send message to " + destination_ // + " build Topic destination end"); // } LOG.debug("send message to " + destination_ + " build destination"); destination = connection.createDestination(session, destination_, destinationType); LOG.debug("send message to " + destination_ + " build destination end."); int deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT; LOG.debug("send message to " + destination_ + " this.client.isPersistent =" + persistent); LOG.debug("send message to " + destination + " send started...."); producer = session.createProducer(destination); if (properties != null) MQUtil.initMessage(message, properties); producer.send(message, deliveryMode, priority, timeToLive); LOG.debug("send message to " + destination + " send end...."); if (LOG.isDebugEnabled()) { LOG.debug("Sent! to destination: " + destination + " message: " + message); } } catch (JMSException e) { throw e; } catch (Exception e) { throw new JMSException(e.getMessage()); } finally { if (producer != null) try { producer.close(); } catch (Exception e) { } } }
From source file:com.oneops.daq.jms.SensorPublisher.java
/** * Publish message./*from ww w . j a v a 2 s . co m*/ * * @param event the event * @throws JMSException the jMS exception */ public void publishMessage(final BasicEvent event) throws JMSException { if (System.currentTimeMillis() > lastFailureTimestamp) { int shard = (int) (event.getManifestId() % poolsize); try { producers[shard].send(session -> { ObjectMessage message = session.createObjectMessage(event); message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT); message.setLongProperty("ciId", event.getCiId()); message.setLongProperty("manifestId", event.getManifestId()); message.setStringProperty("source", event.getSource()); if (logger.isDebugEnabled()) { logger.debug("Published: ciId:" + event.getCiId() + "; source:" + event.getSource()); } return message; }); lastFailureTimestamp = -1; } catch (JmsException exception) { logger.warn("There was an error sending a message. Discarding messages for " + mqConnectionThreshold + " ms"); lastFailureTimestamp = System.currentTimeMillis() + mqConnectionThreshold; } } }
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 w w w .j av a 2 s.c o m 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:org.apache.activemq.artemis.tests.integration.persistence.metrics.JournalPendingMessageTest.java
@Test public void testQueueMessageSizeAfterConsumptionNonPersistent() throws Exception { AtomicLong publishedMessageSize = new AtomicLong(); publishTestQueueMessages(200, DeliveryMode.NON_PERSISTENT, publishedMessageSize); verifyPendingStats(defaultQueueName, 200, publishedMessageSize.get()); consumeTestQueueMessages(200);//from w w w. j a va 2 s . c om verifyPendingStats(defaultQueueName, 0, 0); verifyPendingDurableStats(defaultQueueName, 0, 0); }
From source file:org.openanzo.combus.endpoint.BaseServiceListener.java
private void processMessage(Message request) { try {//from w w w . j ava2 s . c o m IOperationContext context = null; TextMessage response = null; String operation = request.getStringProperty(SerializationConstants.operation); try { Destination replyTo = null; try { if (mp == null) { mp = session.createProducer(null); mp.setDeliveryMode(DeliveryMode.NON_PERSISTENT); } replyTo = request.getJMSReplyTo(); String resultFormat = request.getStringProperty(SerializationConstants.resultFormat); context = new BaseOperationContext(operation, request.getJMSCorrelationID(), null); if (request.propertyExists(SerializationConstants.userDescription)) { context.setAttribute(SerializationConstants.userDescription, request.getStringProperty(SerializationConstants.userDescription)); } if (request.propertyExists(OPTIONS.SKIPCACHE)) { context.setAttribute(OPTIONS.SKIPCACHE, request.getBooleanProperty(OPTIONS.SKIPCACHE)); } if (request.propertyExists(OPTIONS.INCLUDEMETADATAGRAPHS)) { context.setAttribute(OPTIONS.INCLUDEMETADATAGRAPHS, request.getBooleanProperty(OPTIONS.INCLUDEMETADATAGRAPHS)); } AnzoPrincipal callerPrincipal = getContextPrincipal(context, request); context.setOperationPrincipal(callerPrincipal); if (log.isTraceEnabled()) { log.trace(LogUtils.COMBUS_MARKER, MessageUtils.prettyPrint(request, "Message Recieved from [" + callerPrincipal.getName() + "]" + ((replyTo != null) ? (" with replyto [" + replyTo + "]") : ""))); } else if (log.isDebugEnabled()) { log.debug(LogUtils.COMBUS_MARKER, "Message Recieved from [" + callerPrincipal.getName() + "]" + ((replyTo != null) ? (" with replyto [" + replyTo + "]") : "")); } context.setMDC(); Boolean analyzeRequest = request .getBooleanProperty(RequestAnalysis.CONTEXT_PROP_REQUEST_ENABLED); if (analyzeRequest || recorder != null) { RequestAnalysis.setCurrentContext(context.getAttributes()); RequestAnalysis.setRequestAnalysisEnabled(true); } if (recorder != null) { recorder.recordRequest((TextMessage) request, request.getStringProperty("JMSXUserID"), request.getStringProperty(SerializationConstants.runAsUser)); } long start = 0, end = 0; if (RequestAnalysis.isAnalysisEnabled(context.getAttributes())) { start = System.currentTimeMillis(); } response = handleMessage(context, replyTo, resultFormat, operation, (TextMessage) request, mp); if (RequestAnalysis.isAnalysisEnabled(context.getAttributes())) { end = System.currentTimeMillis(); RequestAnalysis.addAnalysisProperty(RequestAnalysis.ANS_PROP_OPERATION_TIME, String.valueOf(end - start)); } if (response != null) { response.setIntProperty(SerializationConstants.protocolVersion, Constants.VERSION); if (operation != null) { response.setStringProperty(SerializationConstants.operation, operation); } Integer totalSolutions = context.getAttribute(SerializationConstants.totalSolutions, Integer.class); if (totalSolutions != null) { response.setIntProperty(SerializationConstants.totalSolutions, totalSolutions.intValue()); } if (analyzeRequest) { for (String name : RequestAnalysis.getAnalysisPropertyNames()) { response.setStringProperty(name, context.getAttribute(name).toString()); } } } if (response != null && replyTo != null) { response.setJMSCorrelationID(request.getJMSCorrelationID()); if (log.isTraceEnabled()) { log.trace(LogUtils.COMBUS_MARKER, MessageUtils.prettyPrint(response, "Sending Response to [" + replyTo + "]")); } else if (log.isDebugEnabled()) { log.debug(LogUtils.COMBUS_MARKER, "Sending Response to [" + replyTo + "]"); } mp.send(replyTo, response); } } catch (JMSException jmex) { response = sendJMSErrorMessage(replyTo, request, jmex, ExceptionConstants.COMBUS.JMS_SERVICE_EXCEPTION, jmex.toString()); } catch (AnzoException jmex) { response = sendJMSErrorMessage(replyTo, request, jmex, jmex.getErrorCode(), jmex.getArgs()); } catch (AnzoRuntimeException jmex) { response = sendJMSErrorMessage(replyTo, request, jmex, jmex.getErrorCode(), jmex.getArgs()); } catch (RuntimeException jmex) { response = sendJMSErrorMessage(replyTo, request, jmex, ExceptionConstants.COMBUS.JMS_SERVICE_EXCEPTION, jmex.toString()); } catch (Throwable jmex) { response = sendJMSErrorMessage(replyTo, request, jmex, ExceptionConstants.COMBUS.JMS_SERVICE_EXCEPTION, jmex.toString()); } if (recorder != null) { if (response != null) { recorder.recordResponse(response); } else { recorder.recordResponse(request.getJMSCorrelationID(), operation); } } } finally { if (context != null) { context.clearMDC(); } } } catch (JMSException jmsex) { if (jmsex.getCause() instanceof InterruptedException) { log.debug(LogUtils.COMBUS_MARKER, "Thread interrupted in order to stop.", jmsex); } else { log.error(LogUtils.COMBUS_MARKER, "Error in BaseService Listener's process thread loop", jmsex); } } catch (Throwable jmex) { log.error(LogUtils.COMBUS_MARKER, "Error in BaseService Listener's process thread loop", jmex); } }
From source file:org.openanzo.combus.bayeux.BridgeConnectionManager.java
/** * Creates a single JMS connection and session for use by the BayeuxJMSBridge. It connects to the combus using a configured sysadmin account. * /*from w ww .ja va 2 s . c o m*/ * @param factory * this will be used to create the JMS connection and session. * @param properties * must contain the username and password * @throws JMSException */ protected void initialize(ConnectionFactory factory, Properties properties) throws AnzoException { try { conn = factory.createConnection(credentials.getUserName(), credentials.getPassword()); conn.setExceptionListener(new ExceptionListener() { public void onException(JMSException exception) { if (!closed) { // if user has not requested disconnect if (exception.getCause() instanceof BrokerStoppedException || exception.getCause() instanceof TransportDisposedIOException) { closed = true; if (conn != null) { try { conn.close(); } catch (JMSException e) { log.debug(LogUtils.COMBUS_MARKER, "Error closing JMS connection", e); } } } else { log.error(LogUtils.COMBUS_MARKER, "Exception over Bayeux JMS connection", exception); } } } }); conn.start(); session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); mp = session.createProducer(null); mp.setDeliveryMode(DeliveryMode.NON_PERSISTENT); // setup all the destination queues destinations.put(COMBUS.NOTIFICATION_SERVICE_QUEUE, session.createQueue(COMBUS.NOTIFICATION_SERVICE_QUEUE)); destinations.put(COMBUS.MODEL_SERVICE_QUEUE, session.createQueue(COMBUS.MODEL_SERVICE_QUEUE)); destinations.put(COMBUS.UPDATE_SERVICE_QUEUE, session.createQueue(COMBUS.UPDATE_SERVICE_QUEUE)); destinations.put(COMBUS.AUTHENTICATION_SERVICE_QUEUE, session.createQueue(COMBUS.AUTHENTICATION_SERVICE_QUEUE)); destinations.put(COMBUS.REPLICATION_SERVICE_QUEUE, session.createQueue(COMBUS.REPLICATION_SERVICE_QUEUE)); destinations.put(COMBUS.QUERY_SERVICE_QUEUE, session.createQueue(COMBUS.QUERY_SERVICE_QUEUE)); destinations.put(COMBUS.RESET_SERVICE_QUEUE, session.createQueue(COMBUS.RESET_SERVICE_QUEUE)); destinations.put(COMBUS.EXECUTION_SERVICE_QUEUE, session.createQueue(COMBUS.EXECUTION_SERVICE_QUEUE)); destinations.put(COMBUS.AUTHORIZATION_SERVICE_QUEUE, session.createQueue(COMBUS.AUTHORIZATION_SERVICE_QUEUE)); } catch (JMSException jmsex) { throw new AnzoException(ExceptionConstants.COMBUS.JMS_CONNECT_FAILED, jmsex); } }
From source file:com.ccc.ccm.client.JMSTemplateAutowired.java
/** * Set whether message delivery should be persistent or non-persistent, * specified as boolean value ("true" or "false"). This will set the delivery * mode accordingly, to either "PERSISTENT" (1) or "NON_PERSISTENT" (2). * <p>Default it "true" aka delivery mode "PERSISTENT". * @see #setDeliveryMode(int)// w w w . jav a2 s . c om * @see javax.jms.DeliveryMode#PERSISTENT * @see javax.jms.DeliveryMode#NON_PERSISTENT */ public void setDeliveryPersistent(boolean deliveryPersistent) { this.deliveryMode = (deliveryPersistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT); }
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.j a v a 2s . 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> * <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; }