/** * Create a copy of the given {@link Message}. This includes the properties * and the payload * * @param session * @param m * @return copy * @throws JMSException */ @SuppressWarnings("unchecked") protected Message copy(Session session, Message m) throws JMSException { ObjectMessage message = (ObjectMessage) m; ObjectMessage copy = session.createObjectMessage(message.getObject()); Enumeration<String> properties = message.getPropertyNames(); while (properties.hasMoreElements()) { String name = properties.nextElement(); copy.setObjectProperty(name, message.getObjectProperty(name)); } return copy; }
protected void sendExternalEvent(CayenneEvent localEvent) throws Exception { ObjectMessage message = sendSession .createObjectMessage(eventToMessageObject(localEvent)); message.setObjectProperty(JMSBridge.VM_ID_PROPERRTY, JMSBridge.VM_ID); publisher.publish(message); }
protected void sendExternalEvent(CayenneEvent localEvent) throws Exception { ObjectMessage message = sendSession .createObjectMessage(eventToMessageObject(localEvent)); message.setObjectProperty(JMSBridge.VM_ID_PROPERRTY, JMSBridge.VM_ID); publisher.publish(message); }
/** * Produce the mail to the JMS Queue */ protected void produceMail(Map<String, Object> props, int msgPrio, Mail mail) throws JMSException, MessagingException, IOException { ObjectMessage message = session.createObjectMessage(); for (Map.Entry<String, Object> entry : props.entrySet()) { message.setObjectProperty(entry.getKey(), entry.getValue()); } long size = mail.getMessageSize(); ByteArrayOutputStream out; if (size > -1) { out = new ByteArrayOutputStream((int) size); } else { out = new ByteArrayOutputStream(); } mail.getMessage().writeTo(out); // store the byte array in a ObjectMessage so we can use a // SharedByteArrayInputStream later // without the need of copy the day message.setObject(out.toByteArray()); producer.send(message, Message.DEFAULT_DELIVERY_MODE, msgPrio, Message.DEFAULT_TIME_TO_LIVE); }
@Override public void publishUpdate(Map<String, Object> params, Object body) { if (jmsClient != null) { try { jmsClient.send(params, body, 0L); } catch (Exception e) { log.error("Could not dispatch data update on topic %s using internal JMS client, message %s", topicName, body.toString()); } } else if (enabled) { try { Connection jmsConnection = connectionFactory.createConnection(); Session jmsSession = jmsConnection.createSession(transacted, Session.AUTO_ACKNOWLEDGE); MessageProducer jmsProducer = jmsSession.createProducer(topic); ObjectMessage jmsMessage = jmsSession.createObjectMessage((Serializable)body); for (Entry<String, Object> hh : params.entrySet()) jmsMessage.setObjectProperty(hh.getKey(), hh.getValue()); jmsProducer.send(jmsMessage); log.debug("Data message dispatched on JMS topic %s", topicName); } catch (JMSException e) { log.error("Could not dispatch data update on topic %s, message %s", topicName, body.toString()); } } } }
objMsg.setIntProperty(JMSEndpoint.OPN_PROPERTY, operation); objMsg.setStringProperty(JMSEndpoint.EID_PROPERTY, publishEntry.eKey.getFirstSubKey().getValue()); objMsg.setObjectProperty(JMSEndpoint.DID_PROPERTY, publishEntry.eKey.getSecondSubKey()); objMsg.setObjectProperty(JMSEndpoint.OID_PROPERTY, publishEntry.eKey.getThirdSubKey()); objMsg.setObjectProperty(JMSEndpoint.SID_PROPERTY, publishEntry.eKey.getFourthSubKey()); objMsg.setBooleanProperty(JMSEndpoint.MOD_PROPERTY, publishEntry.isModification); objMsg.setObject(publishEntry.update);