List of usage examples for javax.jms Message getStringProperty
String getStringProperty(String name) throws JMSException;
From source file:org.fcrepo.indexer.IndexerGroupTest.java
/** * Creates a mock message an updates the mock HTTPClient to respond to * the expected request for that object. */// w w w . j a v a 2s .c o m private Message createMockMessage(boolean jmsExceptionOnGetMessage, String eventType, String identifier, boolean indexable, String indexerName, boolean property) throws Exception { Message m = mock(Message.class); if (jmsExceptionOnGetMessage) { JMSException e = mock(JMSException.class); when(m.getJMSMessageID()).thenThrow(e); } else { when(m.getJMSMessageID()).thenReturn("mocked-message-id"); } if (eventType != null) { when(m.getStringProperty(IndexerGroup.EVENT_TYPE_HEADER_NAME)).thenReturn(eventType); } if (identifier != null) { when(m.getStringProperty(IndexerGroup.IDENTIFIER_HEADER_NAME)).thenReturn(identifier); mockContent(property ? parentId(identifier) : identifier, indexable, indexerName); } return m; }
From source file:com.fusesource.forge.jmstest.tests.AsyncProducer.java
public void onMessage(Message msg) { try {/*from w ww . ja v a2s . com*/ String recCorrId = msg.getJMSCorrelationID(); synchronized (corrId) { if (recCorrId.equals(corrId)) { receivedResponse = true; String servedBy = msg.getStringProperty("ServedBy"); LOG.debug("Served By : " + servedBy); String brokerStamp = msg.getStringProperty("BrokerStamp"); LOG.debug("BrokerStamp : " + brokerStamp); corrId.notifyAll(); } } } catch (JMSException jme) { LOG.error(jme); } }
From source file:be.fedict.trust.service.bean.DownloaderMDB.java
public void onMessage(Message message) { LOG.debug("onMessage"); DownloadMessage downloadMessage = null; ColdStartMessage coldStartMessage = null; try {/*from w w w . j av a 2s.c o m*/ String messageType = message.getStringProperty(JMSMessage.MESSAGE_TYPE_PROPERTY); if (messageType.equals(DownloadMessage.class.getSimpleName())) { downloadMessage = new DownloadMessage(message); } else if (messageType.equals(ColdStartMessage.class.getSimpleName())) { coldStartMessage = new ColdStartMessage(message); } } catch (JMSException e) { LOG.error("JMS error: " + e.getMessage(), e); return; } processDownloadMessage(downloadMessage); processColdStartMessage(coldStartMessage); }
From source file:com.adaptris.core.jms.MetadataHandler.java
private MetadataCollection createMetadataCollection(Message in) throws JMSException { MetadataCollection result = new MetadataCollection(); Enumeration props = in.getPropertyNames(); while (props.hasMoreElements()) { String key = (String) props.nextElement(); String value = in.getStringProperty(key); // converts all to Strings if (!isEmpty(value)) { result.add(new MetadataElement(key, value)); } else {/* www .j av a 2s.c o m*/ log.debug("ignoring null or empty metadata value against key [" + key + "]"); } } return result; }
From source file:be.fedict.trust.service.bean.HarvesterMDB.java
@SNMP(oid = SnmpConstants.CACHE_REFRESH) public void onMessage(Message message) { LOG.debug("onMessage"); HarvestMessage harvestMessage = null; RemoveCAMessage removeCAMessage = null; try {/*from ww w . j a va 2 s . co m*/ String messageType = message.getStringProperty(JMSMessage.MESSAGE_TYPE_PROPERTY); if (messageType.equals(HarvestMessage.class.getSimpleName())) { harvestMessage = new HarvestMessage(message); } else if (messageType.equals(RemoveCAMessage.class.getSimpleName())) { removeCAMessage = new RemoveCAMessage(message); } } catch (JMSException e) { LOG.error("JMS error: " + e.getMessage(), e); return; } processHarvestMessage(harvestMessage); processRemoveCAMessage(removeCAMessage); }
From source file:com.kinglcc.spring.jms.core.converter.Jackson2JmsMessageConverter.java
protected JavaType getJavaTypeForMessage(Message message) throws JMSException { if (null == this.typeIdPropertyName || !message.propertyExists(this.typeIdPropertyName)) { return null; }// w ww.j a va2 s . c om String typeId = message.getStringProperty(this.typeIdPropertyName); if (typeId == null) { LOGGER.debug("Could not find type id property [{}]", typeIdPropertyName); return null; } try { Class<?> typeClass = ClassUtils.forName(typeId, this.beanClassLoader); return this.objectMapper.getTypeFactory().constructType(typeClass); } catch (Throwable ex) { throw new MessageConversionException("Failed to resolve type id [" + typeId + "]", ex); } }
From source file:com.solveapuzzle.mapping.agnostic.JmsMessageListener.java
/** * Implementation of <code>MessageListener</code>. *//*from w w w .jav a 2 s .c om*/ public void onMessage(Message message) { try { int messageCount = message.getIntProperty(JmsMessageProducer.MESSAGE_COUNT); logger.info("Processed message '{}'. value={}", message, messageCount); counter.incrementAndGet(); if (message instanceof TextMessage) { TextMessage tm = (TextMessage) message; String msg = tm.getText(); logger.info(" Read Transform property " + message.getStringProperty(TRANSFORM)); try { String parser = tm.getStringProperty(PARSER); String key = tm.getStringProperty(TRANSFORM); logger.info(" Read Transform propertys " + parser + " " + key); String response = engine.onTransformEvent(this.createConfig(parser, key), tm.getText(), Charset.defaultCharset()); logger.info(" Response " + response); logger.info("message ReplyTo ID " + tm.getJMSCorrelationID()); tm.setJMSDestination(this.outDestination); javax.jms.Queue queue = (javax.jms.Queue) tm.getJMSDestination(); logger.info("ReplyTo Queue name = " + queue.getQueueName()); tm.clearBody(); tm.setText(response); // Push to response queue } catch (MappingException e) { logger.error("Mapping exception from transformation ", e); // push to mapping error Queue? // May be fixable with input xml change or due to data quality, invalid against schema throw new RuntimeException(e); } catch (ConfigurationException e) { logger.error("Configuration exception from transformation", e); // Can't fix - dead letter queue - but worth tracing what config went missing? throw new RuntimeException(e); } } } catch (JMSException e) { logger.error(e.getMessage(), e); throw new RuntimeException(e); } }
From source file:com.oneops.inductor.Listener.java
/** * MessageListener mapped in application-context.xml - will deserialize to a * WorkOrder (iaas/swdist) or ActionOrder (procedure) * * @param msg Message//from w w w . j ava 2s . c o m * @see javax.jms.MessageListener#onMessage(javax.jms.Message) */ public void onMessage(Message msg) { try { checkFreeSpace(); activeThreads.getAndIncrement(); if (msg instanceof TextMessage) { String msgText = ((TextMessage) msg).getText(); final String correlationID = msg.getJMSCorrelationID(); Map<String, String> responseMsgMap; String type = msg.getStringProperty("type"); CmsWorkOrderSimpleBase wo; // WorkOrder if (type.equals(WORK_ORDER_TYPE)) { long t = System.currentTimeMillis(); wo = getWorkOrderOf(msgText, CmsWorkOrderSimple.class); wo.putSearchTag("iWoCrtTime", Long.toString(System.currentTimeMillis() - t)); preProcess(wo); wo.putSearchTag("rfcAction", wo.getAction()); responseMsgMap = workOrderExecutor.process(wo, correlationID); // ActionOrder } else if (type.equals(ACTION_ORDER_TYPE)) { long t = System.currentTimeMillis(); wo = getWorkOrderOf(msgText, CmsActionOrderSimple.class); wo.putSearchTag("iAoCrtTime", Long.toString(System.currentTimeMillis() - t)); preProcess(wo); responseMsgMap = actionOrderExecutor.process(wo, correlationID); } else { logger.error(new IllegalArgumentException("Unknown msg type - " + type)); msg.acknowledge(); return; } // Controller will process this message responseMsgMap.put("correlationID", correlationID); responseMsgMap.put("type", type); long startTime = System.currentTimeMillis(); if (!correlationID.equals("test")) messagePublisher.publishMessage(responseMsgMap); long endTime = System.currentTimeMillis(); long duration = endTime - startTime; // ack message logger.debug("send message took:" + duration + "ms"); msg.acknowledge(); } } catch (JMSException | SecurityException | IOException | IllegalArgumentException e) { logger.error("Error occurred in processing message", e); } finally { /* * Decrement the total number of active threads consumed by 1 */ activeThreads.getAndDecrement(); clearStateFile(); } }
From source file:com.adaptris.core.jms.MetadataHandler.java
/** * <p>/*from w ww . j a v a 2 s .c o m*/ * Moves metadata from a <code>javax.jms.Message</code> to a <code>AdaptrisMessage</code> if <code>moveMetadata</code> is * <code>true</code>. * </p> * * @param in the JMS <code>Message</code> to move metadata from * @param out the <code>AdaptrisMessage</code> to move metadata to * @return the <code>AdaptrisMessage</code> with metadata added * @throws JMSException */ public final AdaptrisMessage moveMetadata(Message in, AdaptrisMessage out) throws JMSException { if (!(context.metadataFilter() instanceof RemoveAllMetadataFilter)) { MetadataCollection metadata = createMetadataCollection(in); MetadataCollection filtered = context.metadataFilter().filter(metadata); for (MetadataElement e : filtered) { out.addMetadata(e); } } if (!isEmpty(in.getStringProperty(MESSAGE_UNIQUE_ID_KEY))) { out.setUniqueId(in.getStringProperty(MESSAGE_UNIQUE_ID_KEY)); } if (context.moveJmsHeaders()) { this.moveJmsHeaders(in, out); } return out; }
From source file:com.amalto.core.server.routing.DefaultRoutingEngine.java
@Override public void consume(final Message message) { try {/*from w w w . j a v a 2 s .c om*/ @SuppressWarnings("unchecked") String[] rules = getRulesList(message); final String pk = message.getStringProperty(JMS_PK_PROPERTY); final String type = message.getStringProperty(JMS_TYPE_PROPERTY); final String container = message.getStringProperty(JMS_CONTAINER_PROPERTY); final long timeScheduled = message.getLongProperty(JMS_SCHEDULED); final String routingOrderId = message.getJMSMessageID(); for (int ruleIndex = 0; ruleIndex < rules.length; ruleIndex++) { String rule = rules[ruleIndex]; final RoutingRulePOJO routingRule = routingRules.getRoutingRule(new RoutingRulePOJOPK(rule)); // Apparently rule is not (yet) deployed onto this system's DB instance, but... that 's // rather unexpected since all nodes in cluster are supposed to share same system DB. if (routingRule == null) { throw new RuntimeException( "Cannot execute rule(s) " + rules + ": routing rule '" + rule + "' can not be found."); } SecurityConfig.invokeSynchronousPrivateInternal(new Runnable() { @Override public void run() { // execute all rules synchronously final ItemPOJOPK itemPOJOPK = new ItemPOJOPK(new DataClusterPOJOPK(container), type, pk.split("\\.")); applyRule(itemPOJOPK, routingRule, routingOrderId, timeScheduled); } }); } // acknowledge message once all rules are executed message.acknowledge(); } catch (Exception e) { throw new RuntimeException("Unable to process message.", e); } }