private static void attachDebugDetails(ObjectMessage message, String indexName) throws JMSException { String randomUUID = UUID.randomUUID().toString(); message.setStringProperty( "HSearchMsgId", randomUUID ); log.debug( "Enqueueing List<LuceneWork> for index '" + indexName + "' having id " + randomUUID ); }
private static void attachDebugDetails(ObjectMessage message, String indexName) throws JMSException { String randomUUID = UUID.randomUUID().toString(); message.setStringProperty( "HSearchMsgId", randomUUID ); log.debug( "Enqueueing List<LuceneWork> for index '" + indexName + "' having id " + randomUUID ); }
@Override public Message createMessage(Session session) throws JMSException { // ApplicationMessage Objet ObjectMessage objectMessage = session.createObjectMessage(message); // On positionne la propriete de message Applicatif objectMessage.setStringProperty(JmsConstant.APP_JMS_MESSAGE_ID_PROPERTY, JmsConstant.APP_JMS_MESSAGE_ID_VALUE); // On positionne la propriete de message Applicatif objectMessage.setStringProperty(JmsConstant.APP_JMS_MESSAGE_TYPE, message.getType().name()); // On retourne le message return objectMessage; }
protected void sendNotification(ClusterNotification message) { try { ObjectMessage objectMessage = publisherSession.createObjectMessage(); objectMessage.setObject(message); //sign the message, with the name of this node objectMessage.setStringProperty("nodeName", clusterNode); messagePublisher.send(objectMessage); } catch (JMSException e) { log.error("Cannot send notification " + message, e); } }
public void send(Serializable object, String publisherId) { try { ObjectMessage msg = jmsConnector.senderSession.createObjectMessage(object); if(publisherId != null) msg.setStringProperty("publisherId", publisherId); producer.send(msg); // jmsConnector.publish("#sentMessage", object); } catch (JMSException e) { e.printStackTrace(); } } }
private void send(Destination destination, Serializable message, String propertyName, String propertValue, boolean transacted) { Connection connection = null; try { if (transacted) { connection = xaConnectionFactory.createConnection(); } else { connection = connectionFactory.createConnection(); } Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(destination); connection.start(); ObjectMessage objectMessage = session.createObjectMessage(message); if (propertyName != null) { objectMessage.setStringProperty(propertyName, propertValue); } messageProducer.send(objectMessage); } catch (JMSException e) { throw new MessageDeliveryException("Failed to queue push message for further processing", e); } finally { if (connection != null) { try { connection.close(); } catch (JMSException e) { logger.error("Failed to close JMS connection: ", e); } } } } }
private void send(Destination destination, Serializable message, String propertyName, String propertValue, boolean transacted) { Connection connection = null; try { if (transacted) { connection = xaConnectionFactory.createConnection(); } else { connection = connectionFactory.createConnection(); } Session session = connection.createSession(transacted, Session.AUTO_ACKNOWLEDGE); MessageProducer messageProducer = session.createProducer(destination); connection.start(); ObjectMessage objectMessage = session.createObjectMessage(message); if (propertyName != null) { objectMessage.setStringProperty(propertyName, propertValue); } messageProducer.send(objectMessage); } catch (JMSException e) { throw new MessageDeliveryException("Failed to queue push message for further processing", e); } finally { if (connection != null) { try { connection.close(); } catch (JMSException e) { logger.error("Failed to close JMS connection: ", e); } } } } }
protected void sendNotification(ClusterNotification message) { try { ObjectMessage objectMessage = publisherSession.createObjectMessage(); objectMessage.setObject(message); //sign the message, with the name of this node objectMessage.setStringProperty("nodeName", clusterNode); publisher.publish(objectMessage); } catch (JMSException e) { log.error("Cannot send notification " + message, e); } } }
final Object value = property.getValue(); if (value instanceof String) { objectMessage.setStringProperty(property.getKey(), (String) value); } else if (value instanceof Long) { objectMessage.setLongProperty(property.getKey(), (Long) value);
final Object value = property.getValue(); if (value instanceof String) { objectMessage.setStringProperty(property.getKey(), (String) value); } else if (value instanceof Long) { objectMessage.setLongProperty(property.getKey(), (Long) value);
public void post(final SysEventBase ev) throws NotificationException { try { final ObjectMessage msg = conn.getSession().createObjectMessage(); msg.setObject(ev); for (final Attribute attr: ev.getMessageAttributes()) { msg.setStringProperty(attr.name, attr.value); } long start = System.currentTimeMillis(); sender.send(msg); sends++; sendTime += System.currentTimeMillis() - start; } catch (final JMSException je) { throw new NotificationException(je); } }
message.setStringProperty(TaskServiceConstants.SELECTOR_NAME, this.selector); message.setObject((Serializable)object);
public void write(Object message) throws IOException { try { ObjectMessage clientMessage = this.session.createObjectMessage(); clientMessage.setObject((Serializable) message); clientMessage.setStringProperty(TaskServiceConstants.SELECTOR_NAME, this.selector); this.producer.send(clientMessage); } catch (JMSException e) { throw new IOException("Unable to create message: " + e.getMessage()); } finally { try { if(this.session.getTransacted()) { this.session.commit(); } } catch (JMSException e) { throw new IOException("Unable to commit message: " + e.getMessage()); } } } }
private void jmsSendMessage(Serializable value, String destName, boolean isQueue) throws JMSException { ConnectionFactory factory = new ActiveMQJMSConnectionFactory("tcp://localhost:61616"); String jmsDest; if (isQueue) { jmsDest = QUEUE_QUALIFIED_PREFIX + destName; } else { jmsDest = TOPIC_QUALIFIED_PREFIX + destName; } Destination destination = ActiveMQDestination.fromPrefixedName(jmsDest); Connection conn = factory.createConnection(); try { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(destination); ObjectMessage message = session.createObjectMessage(); message.setStringProperty(HttpHeaderProperty.CONTENT_TYPE, "application/xml"); message.setObject(value); producer.send(message); } finally { conn.close(); } } }
Queue q = (Queue) ServiceLocator.getInstance().getDestination("QUEUE"); QueueConnectionFactory factory = (QueueConnectionFactory) ServiceLocator.getInstance().getConnectionFactory( "java:/ConnectionFactory"); QueueConnection connection = factory.createQueueConnection(); QueueSession session = null; QueueSender sender = null; session = connection.createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE); sender = session.createSender(q); ObjectMessage msg = session.createObjectMessage(); if (redelivedCount > 0) { msg.setIntProperty("redelivedCount", redelivedCount); // schedule to run in 10 secs msg.setLongProperty("_AMQ_SCHED_DELIVERY", System.currentTimeMillis() + 10000); } msg.setStringProperty("action", action); msg.setObject(params); sender.send(msg);
reply.setStringProperty("responder", name); reply.setJMSCorrelationID(objectMessage.getJMSMessageID());
ObjectMessage message = session.createObjectMessage(); message.setObject( data ); message.setStringProperty( Environment.INDEX_NAME_JMS_PROPERTY, indexName ); if ( log.isDebugEnabled() ) { attachDebugDetails( message, indexName );
ObjectMessage message = session.createObjectMessage(); message.setObject( data ); message.setStringProperty( Environment.INDEX_NAME_JMS_PROPERTY, indexName ); if ( log.isDebugEnabled() ) { attachDebugDetails( message, indexName );
private void sendMessage(List<LuceneWork> queue) throws Exception { ObjectMessage message = getQueueSession().createObjectMessage(); final String indexName = getIndexName(); message.setStringProperty( Environment.INDEX_NAME_JMS_PROPERTY, indexName ); byte[] data = getExtendedSearchIntegrator().getWorkSerializer().toSerializedModel( queue ); message.setObject( data ); QueueSender sender = getQueueSession().createSender( getMessageQueue() ); sender.send( message ); }
objMessage.setStringProperty("testName", "testSendEmptyMessages"); defaultSender.send(objMessage); assertNotNull("Didn't receive message", queueReceiver.receive(1000));