List of usage examples for javax.jms ObjectMessage setJMSCorrelationID
void setJMSCorrelationID(String correlationID) throws JMSException;
From source file:com.alliander.osgp.adapter.ws.core.infra.jms.CommonRequestMessageSender.java
/** * Method for sending a request message to the public lighting requests * queue//from w ww. ja va2 s . c o m * * @param requestMessage * The CommonRequestMessage request message to send. */ private void sendMessage(final CommonRequestMessage requestMessage) { LOGGER.info("Sending request message to common requests queue"); this.commonRequestsJmsTemplate.send(new MessageCreator() { @Override public Message createMessage(final Session session) throws JMSException { final ObjectMessage objectMessage = session.createObjectMessage(requestMessage.getRequest()); objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid()); objectMessage.setJMSType(requestMessage.getMessageType().toString()); objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification()); objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification()); if (requestMessage.getScheduleTime() != null) { objectMessage.setLongProperty(Constants.SCHEDULE_TIME, requestMessage.getScheduleTime().getMillis()); } return objectMessage; } }); }
From source file:com.alliander.osgp.adapter.ws.publiclighting.infra.jms.PublicLightingRequestMessageSender.java
/** * Method for sending a request message to the public lighting requests * queue// w w w .j a v a2 s . c om * * @param requestMessage * The PublicLightingRequestMessage request message to send. */ private void sendMessage(final PublicLightingRequestMessage requestMessage) { LOGGER.info("Sending message to the public lighting requests queue"); this.publicLightingRequestsJmsTemplate.send(new MessageCreator() { @Override public Message createMessage(final Session session) throws JMSException { final ObjectMessage objectMessage = session.createObjectMessage(requestMessage.getRequest()); objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid()); objectMessage.setJMSType(requestMessage.getMessageType().toString()); objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification()); objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification()); if (requestMessage.getScheduleTime() != null) { objectMessage.setLongProperty(Constants.SCHEDULE_TIME, requestMessage.getScheduleTime().getMillis()); } return objectMessage; } }); }
From source file:com.alliander.osgp.adapter.ws.tariffswitching.infra.jms.TariffSwitchingRequestMessageSender.java
/** * Method for sending a request message to the public lighting requests * queue// ww w. j ava 2 s.c o m * * @param requestMessage * The TariffSwitchingRequestMessage request message to send. */ private void sendMessage(final TariffSwitchingRequestMessage requestMessage) { LOGGER.info("Sending message to the tariff switching requests queue"); this.tariffSwitchingRequestsJmsTemplate.send(new MessageCreator() { @Override public Message createMessage(final Session session) throws JMSException { final ObjectMessage objectMessage = session.createObjectMessage(requestMessage.getRequest()); objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid()); objectMessage.setJMSType(requestMessage.getMessageType().toString()); objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification()); objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification()); if (requestMessage.getScheduleTime() != null) { objectMessage.setLongProperty(Constants.SCHEDULE_TIME, requestMessage.getScheduleTime().getMillis()); } return objectMessage; } }); }
From source file:com.cws.esolutions.agent.mq.MQMessageHandler.java
public void onMessage(final Message message) { final String methodName = MQMessageHandler.CNAME + "#onMessage(final Message message)"; if (DEBUG) {/*from w ww .ja v a 2 s.c om*/ DEBUGGER.debug(methodName); DEBUGGER.debug("Message: {}", message); } final Session session = agentBean.getSession(); final MessageProducer producer = agentBean.getProducer(); final Destination destination = MQMessageHandler.agentBean.getResponseQueue(); if (DEBUG) { DEBUGGER.debug("Session: {}", session); DEBUGGER.debug("MessageProducer: {}", producer); DEBUGGER.debug("Destination: {}", destination); } try { ObjectMessage mqMessage = (ObjectMessage) message; if (DEBUG) { DEBUGGER.debug("mqMessage: {}", mqMessage); } if ((StringUtils.equals(MQMessageHandler.serverConfig.getRequestQueue(), MQMessageHandler.serverConfig.getResponseQueue())) && (mqMessage.getObject() instanceof AgentResponse)) { return; } AgentRequest agentRequest = (AgentRequest) mqMessage.getObject(); if (DEBUG) { DEBUGGER.debug("agentRequest: {}", agentRequest); } mqMessage.acknowledge(); AgentResponse agentResponse = MQMessageHandler.processor.processRequest(agentRequest); if (DEBUG) { DEBUGGER.debug("AgentResponse: {}", agentResponse); } ObjectMessage oMessage = session.createObjectMessage(true); oMessage.setObject(agentResponse); oMessage.setJMSCorrelationID(message.getJMSCorrelationID()); if (DEBUG) { DEBUGGER.debug("ObjectMessage: {}", oMessage); } producer.send(destination, oMessage); } catch (JMSException jx) { ERROR_RECORDER.error(jx.getMessage(), jx); } catch (AgentException ax) { ERROR_RECORDER.error(ax.getMessage(), ax); } }
From source file:com.alliander.osgp.adapter.protocol.oslp.elster.infra.messaging.SigningServerRequestMessageSender.java
public void send(final RequestMessage requestMessage, final String messageType) { LOGGER.info("Sending request message to signing server, with reply-to-queue: {}.", this.replyToQueue.toString()); this.signingServerRequestsJmsTemplate.send(new MessageCreator() { @Override//from ww w. j a v a2s. co m public Message createMessage(final Session session) throws JMSException { final ObjectMessage objectMessage = session.createObjectMessage(requestMessage); objectMessage.setJMSType(messageType); objectMessage.setJMSReplyTo(SigningServerRequestMessageSender.this.replyToQueue); objectMessage.setJMSCorrelationID(requestMessage.getCorrelationUid()); objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, requestMessage.getOrganisationIdentification()); objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, requestMessage.getDeviceIdentification()); return objectMessage; } }); }
From source file:biz.fstechnology.micro.common.jms.RequestMessageCreator.java
/** * @see org.springframework.jms.core.MessageCreator#createMessage(javax.jms.Session) */// w w w . j a v a 2 s. co m @Override public Message createMessage(Session session) throws JMSException { ObjectMessage message = session.createObjectMessage(); message.setObject(getContents()); message.setJMSReplyTo(getReplyTo()); if (getRequestId() == null) { setRequestId(Double.toHexString(Math.random())); } message.setJMSCorrelationID(getRequestId()); return message; }
From source file:nl.nn.adapterframework.jms.JmsTransactionalStorage.java
public String storeMessage(String messageId, String correlationId, Date receivedDate, String comments, String label, Serializable message) throws SenderException { Session session = null;// ww w. jav a 2s. co m try { session = createSession(); ObjectMessage msg = session.createObjectMessage(message); msg.setStringProperty(FIELD_TYPE, getType()); msg.setStringProperty(FIELD_ORIGINAL_ID, messageId); msg.setJMSCorrelationID(correlationId); msg.setLongProperty(FIELD_RECEIVED_DATE, receivedDate.getTime()); msg.setStringProperty(FIELD_COMMENTS, comments); if (StringUtils.isNotEmpty(getSlotId())) { msg.setStringProperty(FIELD_SLOTID, getSlotId()); } msg.setStringProperty(FIELD_LABEL, label); return send(session, getDestination(), msg); } catch (Exception e) { throw new SenderException(e); } finally { closeSession(session); } }
From source file:com.cognifide.aet.runner.distribution.dispatch.CollectionResultsRouter.java
private void createAndSendComparatorJobData(Step step, String testName, String urlName) throws JMSException { ObjectMessage message = session.createObjectMessage(new ComparatorJobData(suite.get().getCompany(), suite.get().getProject(), suite.get().getName(), testName, urlName, step)); message.setJMSCorrelationID(correlationId); sender.send(message);//w ww. j a v a2s. c o m }
From source file:org.wso2.carbon.identity.agent.outbound.server.UserStoreServerEndpoint.java
/** * Process response message and send to response queue. * @param message Message/*w ww . j a v a 2 s . c om*/ */ private void processResponse(String message) { JMSConnectionFactory connectionFactory = new JMSConnectionFactory(); Connection connection = null; MessageProducer producer; try { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Start processing response message: " + message); } MessageBrokerConfig conf = ServerConfigurationBuilder.build().getMessagebroker(); connectionFactory.createActiveMQConnectionFactory(conf.getUrl()); connection = connectionFactory.createConnection(); connectionFactory.start(connection); javax.jms.Session session = connectionFactory.createSession(connection); Destination responseQueue = connectionFactory.createQueueDestination(session, UserStoreConstants.QUEUE_NAME_RESPONSE); producer = connectionFactory.createMessageProducer(session, responseQueue, DeliveryMode.NON_PERSISTENT); producer.setTimeToLive(UserStoreConstants.QUEUE_SERVER_MESSAGE_LIFETIME); JSONObject resultObj = new JSONObject(message); String responseData = resultObj.get(UserStoreConstants.UM_JSON_ELEMENT_RESPONSE_DATA).toString(); String correlationId = (String) resultObj .get(UserStoreConstants.UM_JSON_ELEMENT_REQUEST_DATA_CORRELATION_ID); UserOperation responseOperation = new UserOperation(); responseOperation.setCorrelationId(correlationId); responseOperation.setResponseData(responseData.toString()); ObjectMessage responseMessage = session.createObjectMessage(); responseMessage.setObject(responseOperation); responseMessage.setJMSCorrelationID(correlationId); producer.send(responseMessage); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Finished processing response message: " + message); } } catch (JMSException e) { LOGGER.error("Error occurred while sending message: " + message, e); } catch (JSONException e) { LOGGER.error("Error occurred while reading json payload of message: " + message, e); } catch (JMSConnectionException e) { LOGGER.error("Error occurred while creating JMS connection to send message: " + message, e); } finally { try { connectionFactory.closeConnection(connection); } catch (JMSConnectionException e) { LOGGER.error("Error occurred while closing JMS connection", e); } } }
From source file:org.oxymores.chronix.engine.Runner.java
public void sendRunDescription(RunDescription rd, Place p, PipelineJob pj) throws JMSException { // Always send to the node, not its hosting node. String qName = String.format(Constants.Q_RUNNER, p.getNode().getBrokerName()); log.info(String.format("A command will be sent for execution on queue %s (%s)", qName, rd.getCommand())); Destination destination = jmsSession.createQueue(qName); ObjectMessage m = jmsSession.createObjectMessage(rd); m.setJMSReplyTo(destEndJob);/*www. ja va 2s . c om*/ m.setJMSCorrelationID(pj.getId()); producerRunDescription.send(destination, m); jmsSession.commit(); }