List of usage examples for javax.jms ObjectMessage setJMSDeliveryMode
void setJMSDeliveryMode(int deliveryMode) throws JMSException;
From source file:com.oneops.daq.jms.SensorPublisher.java
/** * Publish message./* w w w. j ava 2 s . c o 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; } } }