public Object getObjectProperty(Message jmsMessage, String name) throws JMSException { // try a direct lookup first Object answer = jmsMessage.getObjectProperty(name); if (answer == null) { // then encode the key and do another lookup String key = jmsKeyFormatStrategy.encodeKey(name); answer = jmsMessage.getObjectProperty(key); } return answer; }
public void invalidateObject(Session session, javax.jms.Message msg) throws javax.jms.JMSException { String tableName = msg.getStringProperty("TABLE"); if (tableName == null) { return; } Class baseClass = (Class) tableNameToClass.get(tableName); if (baseClass == null) { return; } Vector pkFieldNames = (Vector) tableNameToPkFieldNames.get(tableName); if (pkFieldNames == null) { return; } // create DatabaseRecord corresponding to the message DatabaseRecord row = new DatabaseRecord(pkFieldNames.size()); for (int i = 0; i < pkFieldNames.size(); i++) { String fieldName = (String) pkFieldNames.elementAt(i); Object value = msg.getObjectProperty(fieldName); row.put(fieldName, value); } // invalidate in TopLink cache the object corresponding to the row and the baseClass session.getIdentityMapAccessor().invalidateObject(row, baseClass); }
public static Hashtable getDataTable(Message message) throws JMSException { if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { return DATA_TABLE_DEF; } return (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE); }
@Override public MessageDetails createMessageDetailsFor(Destination incomingDestination, Message message) { try { Destination replyTo = message.getJMSReplyTo(); String correlationId = message.getJMSCorrelationID(); Map<String, String> customHeaders = null; if (correlationId != null && replyTo != null) { customHeaders = new HashMap<String, String>(3, 1.0f); Enumeration<String> enumeration = message.getPropertyNames(); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); customHeaders.put(key, String.valueOf(message.getObjectProperty(key))); } } return new MessageDetails.Builder<Destination>() .withDestination(incomingDestination) .withCorrelationId(correlationId) .withReplyTo(replyTo) .withCustomHeaders(customHeaders) .build(); } catch (JMSException e) { throw new RuntimeException("Unable to parse incoming message", e); } }
protected JBossMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException { this(type, session); setJMSTimestamp(foreign.getJMSTimestamp()); try { byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes(); setJMSCorrelationIDAsBytes(corrIDBytes); } catch (JMSException e) { // specified as String String corrIDString = foreign.getJMSCorrelationID(); if (corrIDString != null) { setJMSCorrelationID(corrIDString); } } setJMSReplyTo(foreign.getJMSReplyTo()); setJMSDestination(foreign.getJMSDestination()); setJMSDeliveryMode(foreign.getJMSDeliveryMode()); setJMSExpiration(foreign.getJMSExpiration()); setJMSPriority(foreign.getJMSPriority()); setJMSType(foreign.getJMSType()); // We can't avoid a cast warning here since getPropertyNames() is on the JMS API for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) { String name = (String) props.nextElement(); Object prop = foreign.getObjectProperty(name); this.setObjectProperty(name, prop); } }
static Map<String, Object> mockAttributes(Message message) throws JMSException { final Map<String, Object> mockMap = new HashMap<String, Object>(); mockMap.put("test-string", "test-value"); mockMap.put("test-int", Integer.valueOf(1)); when(message.getPropertyNames()) .thenReturn( new Enumeration<String>() { Iterator<String> iter = mockMap.keySet().iterator(); public boolean hasMoreElements() { return iter.hasNext(); } public String nextElement() { return iter.next(); } }); when(message.getObjectProperty( argThat( new BaseMatcher<String>() { public boolean matches(Object val) { return "test-string".equals(val); } public void describeTo(Description desc) { // do nothing } }))) .thenReturn(mockMap.get("test-string")); when(message.getObjectProperty( argThat( new BaseMatcher<String>() { public boolean matches(Object val) { return "test-int".equals(val); } public void describeTo(Description desc) { // do nothing } }))) .thenReturn(mockMap.get("test-int")); return mockMap; }
/** * Get property * * @param name The name * @return The value * @throws JMSException Thrown if an error occurs */ @Override public Object getObjectProperty(final String name) throws JMSException { if (ActiveMQRAMessage.trace) { ActiveMQRALogger.LOGGER.trace("getObjectProperty(" + name + ")"); } return message.getObjectProperty(name); }
public static Hashtable getAttachments(Message message) throws JMSException { if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { return ATTACHMENT_TABLE_DEF; } Hashtable attachments = new Hashtable(); attachments.putAll((Map) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE)); return attachments; }
public static Object getDataEntry(Message message, Object name) throws JMSException { if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { return DATA_PROP_DEF; } Hashtable datTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE); return datTable.get(name); }
public static Object getAttachment(Message message, String name) throws JMSException { if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { return ATTACHMENT_PROP_DEF; } Hashtable attachmentTable; attachmentTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE); return attachmentTable.get(name); }
public static Object getPropertyValue(String propertyName, Message jmsMessage) throws JMSException { if (jmsMessage == null) { return null; } if (propertyName == null) { return null; } return jmsMessage.getObjectProperty(propertyName); }
@SuppressWarnings("unchecked") private static Map<String, Object> properties(final javax.jms.Message message) throws JMSException { final HashMap<String, Object> result = new HashMap<>(); final Enumeration<String> propertyNames = message.getPropertyNames(); while (propertyNames.hasMoreElements()) { final String propertyName = propertyNames.nextElement(); result.put(propertyName, message.getObjectProperty(propertyName)); } result.put(JMS_MESSAGE_TYPE, getJmsMessageType(message)); return result; }
protected HornetQMessage(final Message foreign, final byte type, final ClientSession session) throws JMSException { this(type, session); setJMSTimestamp(foreign.getJMSTimestamp()); String value = System.getProperty( HornetQJMSConstants.JMS_HORNETQ_ENABLE_BYTE_ARRAY_JMS_CORRELATION_ID_PROPERTY_NAME); boolean supportBytesId = !"false".equals(value); if (supportBytesId) { try { byte[] corrIDBytes = foreign.getJMSCorrelationIDAsBytes(); setJMSCorrelationIDAsBytes(corrIDBytes); } catch (JMSException e) { // specified as String String corrIDString = foreign.getJMSCorrelationID(); if (corrIDString != null) { setJMSCorrelationID(corrIDString); } } } else { // Some providers, like WSMQ do automatic conversions between native byte[] correlation id // and String correlation id. This makes it impossible for HQ to guarantee to return the // correct // type as set by the user // So we allow the behaviour to be overridden by a system property // https://jira.jboss.org/jira/browse/HORNETQ-356 // https://jira.jboss.org/jira/browse/HORNETQ-332 String corrIDString = foreign.getJMSCorrelationID(); if (corrIDString != null) { setJMSCorrelationID(corrIDString); } } setJMSReplyTo(foreign.getJMSReplyTo()); setJMSDestination(foreign.getJMSDestination()); setJMSDeliveryMode(foreign.getJMSDeliveryMode()); setJMSExpiration(foreign.getJMSExpiration()); setJMSPriority(foreign.getJMSPriority()); setJMSType(foreign.getJMSType()); // We can't avoid a cast warning here since getPropertyNames() is on the JMS API for (Enumeration<String> props = foreign.getPropertyNames(); props.hasMoreElements(); ) { String name = props.nextElement(); Object prop = foreign.getObjectProperty(name); setObjectProperty(name, prop); } }
public Map<String, Object> getPropertiesMap() throws JMSException { Map<String, Object> answer = new HashMap<String, Object>(); Message aMessage = getMessage(); Enumeration iter = aMessage.getPropertyNames(); while (iter.hasMoreElements()) { String name = (String) iter.nextElement(); Object value = aMessage.getObjectProperty(name); if (value != null) { answer.put(name, value); } } return answer; }
/** * Test that a <code>null</code> value is returned by the <code>Message.getObjectProperty()</code> * method if a property by the specified name does not exits. */ @Test public void testGetObjectProperty() { try { Message message = senderSession.createMessage(); Assert.assertEquals( "sec. 3.5.5 A null value is returned [by the getObjectProperty method] if a property by the specified " + "name does not exits.\n", null, message.getObjectProperty("prop")); } catch (JMSException e) { fail(e); } }
public Map<String, Object> extractHeadersFromJms(Message jmsMessage, Exchange exchange) { Map<String, Object> map = new HashMap<String, Object>(); if (jmsMessage != null) { // lets populate the standard JMS message headers try { map.put("JMSCorrelationID", jmsMessage.getJMSCorrelationID()); map.put("JMSDeliveryMode", jmsMessage.getJMSDeliveryMode()); map.put("JMSDestination", jmsMessage.getJMSDestination()); map.put("JMSExpiration", jmsMessage.getJMSExpiration()); map.put("JMSMessageID", jmsMessage.getJMSMessageID()); map.put("JMSPriority", jmsMessage.getJMSPriority()); map.put("JMSRedelivered", jmsMessage.getJMSRedelivered()); map.put("JMSTimestamp", jmsMessage.getJMSTimestamp()); map.put("JMSReplyTo", JmsMessageHelper.getJMSReplyTo(jmsMessage)); map.put("JMSType", JmsMessageHelper.getJMSType(jmsMessage)); // this works around a bug in the ActiveMQ property handling map.put("JMSXGroupID", jmsMessage.getStringProperty("JMSXGroupID")); } catch (JMSException e) { throw new RuntimeCamelException(e); } Enumeration names; try { names = jmsMessage.getPropertyNames(); } catch (JMSException e) { throw new RuntimeCamelException(e); } while (names.hasMoreElements()) { String name = names.nextElement().toString(); try { Object value = jmsMessage.getObjectProperty(name); if (headerFilterStrategy != null && headerFilterStrategy.applyFilterToExternalHeaders(name, value, exchange)) { continue; } // must decode back from safe JMS header name to original header name // when storing on this Camel JmsMessage object. String key = jmsKeyFormatStrategy.decodeKey(name); map.put(key, value); } catch (JMSException e) { throw new RuntimeCamelException(name, e); } } } return map; }
public void onMessage(Message m) { _logger.info("Failover exchange notified cluster membership change"); String currentBrokerIP = ""; try { currentBrokerIP = InetAddress.getByName(_currentBrokerDetail.getHost()).getHostAddress(); } catch (Exception e) { _logger.warn("Unable to resolve current broker host name", e); } List<BrokerDetails> brokerList = new ArrayList<BrokerDetails>(); try { List<String> list = (List<String>) m.getObjectProperty("amq.failover"); for (String brokerEntry : list) { String[] urls = brokerEntry.substring(5).split(","); // Iterate until you find the correct transport // Need to reconsider the logic when the C++ broker supports // SSL URLs. for (String url : urls) { String[] tokens = url.split(":"); if (tokens[0].equalsIgnoreCase(_originalBrokerDetail.getTransport())) { BrokerDetails broker = new AMQBrokerDetails(); broker.setTransport(tokens[0]); broker.setHost(tokens[1]); broker.setPort(Integer.parseInt(tokens[2])); broker.setProperties(_originalBrokerDetail.getProperties()); broker.setSSLConfiguration(_originalBrokerDetail.getSSLConfiguration()); brokerList.add(broker); if (currentBrokerIP.equals(broker.getHost()) && _currentBrokerDetail.getPort() == broker.getPort()) { _currentBrokerIndex = brokerList.indexOf(broker); } break; } } } } catch (JMSException e) { _logger.error("Error parsing the message sent by failover exchange", e); } synchronized (_brokerListLock) { _connectionDetails.setBrokerDetails(brokerList); } _logger.info("============================================================"); _logger.info("Updated cluster membership details " + _connectionDetails); _logger.info("============================================================"); }
public static byte[] getBytesData(Message message) throws JMSException { if (message instanceof BytesMessage) { BytesMessage bytesMessage = (BytesMessage) message; byte bytes[] = new byte[(int) bytesMessage.getBodyLength()]; bytesMessage.readBytes(bytes); return bytes; } if (!message.propertyExists(MessagePropertyNames.BYTES_DATA)) { return BYTES_DATA_DEF; } return (byte[]) message.getObjectProperty(MessagePropertyNames.BYTES_DATA); }
public String send( final T message, final Message correlatedMessage, final String correlationId, final URI dvbEndpointSelector, final String jmsGroupId, final Destination replyQueue) { try { final M jmsMessage = this.messageHandler.createEmptyMessage(this.sessionDelegate); jmsMessage.setJMSCorrelationID(determineCorrelationId(correlationId, correlatedMessage)); Destination replyTo = replyQueue == null ? this.defaultReplyDestinationDelegate.delegate() : replyQueue; if (replyTo != null) { jmsMessage.setJMSReplyTo(replyTo); } final URI temp = DataUtilities.coalesce(dvbEndpointSelector, this.defaultEndpoint); if (temp != null) { jmsMessage.setStringProperty( JMSMessageSender.ENDPOINT_NAMESPACE, dvbEndpointSelector.toASCIIString()); } if (correlatedMessage != null && this.copyPropertyPattern != null) { //noinspection unchecked for (final String name : Collections.list((Enumeration<String>) correlatedMessage.getPropertyNames())) { if (this.copyPropertyPattern.matcher(name).matches()) { if (correlatedMessage.getStringProperty(name) != null) { jmsMessage.setStringProperty(name, correlatedMessage.getStringProperty(name)); } else { jmsMessage.setObjectProperty(name, correlatedMessage.getObjectProperty(name)); } } } } this.messageHandler.fillMessage(message, jmsMessage); if (jmsGroupId != null) { jmsMessage.setStringProperty(JMSMessageSender.JMSX_GROUP_ID, jmsGroupId); } Delegate<MessageProducer> producer = this.producerDelegate; if (correlatedMessage != null && correlatedMessage.getJMSReplyTo() != null) { producer = new JMSMessageProducerDelegate( sessionDelegate, new UnmodifiableDelegate<>(correlatedMessage.getJMSReplyTo())); } producer.delegate().send(jmsMessage); return jmsMessage.getJMSMessageID(); } catch (final JMSException e) { throw DelegatedException.delegate(e); } }
public static void addDataEntry(Message message, Object name, Object value) throws JMSException { Hashtable dataTable = null; if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { dataTable = new Hashtable(); } else { dataTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.DATA_TABLE); } dataTable.put(name, value); if (!message.propertyExists(MessagePropertyNames.DATA_TABLE)) { message.setObjectProperty(MessagePropertyNames.DATA_TABLE, dataTable); } }
public static void addAttachment(Message message, Object name, Object value) throws JMSException { Hashtable headerTable = null; if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { headerTable = new Hashtable(); } else { headerTable = (Hashtable) message.getObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE); } headerTable.put(name, value); if (!message.propertyExists(MessagePropertyNames.ATTACHMENT_TABLE)) { message.setObjectProperty(MessagePropertyNames.ATTACHMENT_TABLE, headerTable); } }
/* * JMS does not let you add a property on received message without first * calling clearProperties, so we need to save and re-add all the old properties so we * don't lose them!! */ private static void copyProperties(final Message msg) throws JMSException { @SuppressWarnings("unchecked") Enumeration<String> en = msg.getPropertyNames(); Map<String, Object> oldProps = null; while (en.hasMoreElements()) { String propName = en.nextElement(); if (oldProps == null) { oldProps = new HashMap<String, Object>(); } oldProps.put(propName, msg.getObjectProperty(propName)); } msg.clearProperties(); if (oldProps != null) { Iterator<Entry<String, Object>> oldPropsIter = oldProps.entrySet().iterator(); while (oldPropsIter.hasNext()) { Entry<String, Object> entry = oldPropsIter.next(); String propName = entry.getKey(); Object val = entry.getValue(); if (val instanceof byte[] == false) { // Can't set byte[] array props through the JMS API - if we're bridging a HornetQ message // it might have such props msg.setObjectProperty(propName, entry.getValue()); } else if (msg instanceof HornetQMessage) { ((HornetQMessage) msg).getCoreMessage().putBytesProperty(propName, (byte[]) val); } } } }
private void convertMessageProperties( final javax.jms.Message message, final MessageImpl replacementMessage) throws JMSException { Enumeration propertyNames = message.getPropertyNames(); while (propertyNames.hasMoreElements()) { String propertyName = String.valueOf(propertyNames.nextElement()); // TODO: Shouldn't need to check for JMS properties here as don't think getPropertyNames() // should return them if (!propertyName.startsWith("JMSX_")) { Object value = message.getObjectProperty(propertyName); replacementMessage.setObjectProperty(propertyName, value); } } replacementMessage.setJMSDeliveryMode(message.getJMSDeliveryMode()); if (message.getJMSReplyTo() != null) { replacementMessage.setJMSReplyTo(message.getJMSReplyTo()); } replacementMessage.setJMSType(message.getJMSType()); replacementMessage.setJMSCorrelationID(message.getJMSCorrelationID()); }
/** {@inheritDoc} */ @Override public void mapFrom(JMSBindingData source, Context context) throws Exception { Message message = source.getMessage(); Enumeration<?> e = message.getPropertyNames(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); if (matches(key)) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { // JMS Message properties -> Context EXCHANGE properties context .setProperty(key, value, Scope.EXCHANGE) .addLabels(JCAComposition.JCA_MESSAGE_PROPERTY); } } } }
@SuppressWarnings("unchecked") public void onMessage(Message message) { log.debug("Receiving a message on {} : {}", SyncJMSMessageProducer.QUEUE_NAME, message); try { String topic = message.getJMSType(); String groupId = (String) message.getStringProperty("path"); String operation = "UNKNOWN"; // A group was DELETED if ("org/sakaiproject/nakamura/lite/authorizables/DELETE".equals(topic) && config.getDeletesEnabled()) { Map<String, Object> attributes = (Map<String, Object>) message.getObjectProperty(StoreListener.BEFORE_EVENT_PROPERTY); grouperManager.deleteGroup(groupId, attributes); operation = "DELETED"; } // A new group was ADDED or an existing group was UPDATED if ("org/sakaiproject/nakamura/lite/authorizables/ADDED".equals(topic) || "org/sakaiproject/nakamura/lite/authorizables/UPDATED".equals(topic)) { // These events should be under org/sakaiproject/nakamura/lite/authorizables/UPDATED // http://jira.sakaiproject.org/browse/KERN-1795 String membersAdded = (String) message.getStringProperty(GrouperEventUtils.MEMBERS_ADDED_PROP); if (membersAdded != null) { // membership adds can be attached to the same event for the group add. grouperManager.createGroup(groupId, config.getGroupTypes()); grouperManager.addMemberships( groupId, Arrays.asList(StringUtils.split(membersAdded, ","))); operation = "ADD_MEMBERS"; } String membersRemoved = (String) message.getStringProperty(GrouperEventUtils.MEMBERS_REMOVED_PROP); if (membersRemoved != null) { grouperManager.removeMemberships( groupId, Arrays.asList(StringUtils.split(membersRemoved, ","))); operation = "REMOVE_MEMBERS"; } if (membersAdded == null && membersRemoved == null) { org.sakaiproject.nakamura.api.lite.Session repositorySession = repository.loginAdministrative(); AuthorizableManager am = repositorySession.getAuthorizableManager(); Group group = (Group) am.findAuthorizable(groupId); repositorySession.logout(); if (groupId.startsWith(ContactsGrouperNameProviderImpl.CONTACTS_GROUPID_PREFIX)) { // TODO Why are we not getting added and removed properties on the Message grouperManager.createGroup(groupId, null); grouperManager.addMemberships(groupId, Arrays.asList(group.getMembers())); operation = "UPDATE CONTACTS"; } else { grouperManager.createGroup(groupId, config.getGroupTypes()); grouperManager.addMemberships(groupId, Arrays.asList(group.getMembers())); operation = "CREATE"; } } } // The message was processed successfully. No exceptions were thrown. // We acknowledge the message and its removed from the queue message.acknowledge(); // We got a message that we didn't know what to do with. if (operation.equals("UNKNOWN")) { log.error( "I don't know what to do with this topic: {}. Turn on debug logs to see the message.", topic); log.debug(message.toString()); } else { log.info("Successfully processed and acknowledged. {}, {}", operation, groupId); log.debug(message.toString()); } } catch (JMSException jmse) { log.error("JMSException while processing message.", jmse); } catch (Exception e) { log.error("Exception while processing message.", e); } }
@SuppressWarnings("unchecked") public void onMessage(Message message) { try { LOGGER.debug("Started handling email jms message."); String nodePath = message.getStringProperty(NODE_PATH_PROPERTY); String contentPath = message.getStringProperty(CONTENT_PATH_PROPERTY); Object objRcpt = message.getObjectProperty(RECIPIENTS); List<String> recipients = null; if (objRcpt instanceof List<?>) { recipients = (List<String>) objRcpt; } else if (objRcpt instanceof String) { recipients = new LinkedList<String>(); String[] rcpts = StringUtils.split((String) objRcpt, ','); for (String rcpt : rcpts) { recipients.add(rcpt); } } if (contentPath != null && contentPath.length() > 0) { javax.jcr.Session adminSession = repository.loginAdministrative(null); org.sakaiproject.nakamura.api.lite.Session sparseSession = StorageClientUtils.adaptToSession(adminSession); try { ContentManager contentManager = sparseSession.getContentManager(); Content messageContent = contentManager.get(contentPath); if (objRcpt != null) { // validate the message if (messageContent != null) { if (messageContent.hasProperty(MessageConstants.PROP_SAKAI_MESSAGEBOX) && (MessageConstants.BOX_OUTBOX.equals( messageContent.getProperty(MessageConstants.PROP_SAKAI_MESSAGEBOX)) || MessageConstants.BOX_PENDING.equals( messageContent.getProperty(MessageConstants.PROP_SAKAI_MESSAGEBOX)))) { if (messageContent.hasProperty(MessageConstants.PROP_SAKAI_MESSAGEERROR)) { // We're retrying this message, so clear the errors messageContent.setProperty( MessageConstants.PROP_SAKAI_MESSAGEERROR, (String) null); } if (messageContent.hasProperty(MessageConstants.PROP_SAKAI_TO) && messageContent.hasProperty(MessageConstants.PROP_SAKAI_FROM)) { // make a commons-email message from the message MultiPartEmail email = null; try { email = constructMessage(messageContent, recipients, adminSession, sparseSession); email.setSmtpPort(smtpPort); email.setHostName(smtpServer); email.send(); } catch (EmailException e) { String exMessage = e.getMessage(); Throwable cause = e.getCause(); setError(messageContent, exMessage); LOGGER.warn("Unable to send email: " + exMessage); // Get the SMTP error code // There has to be a better way to do this boolean rescheduled = false; if (cause != null && cause.getMessage() != null) { String smtpError = cause.getMessage().trim(); try { int errorCode = Integer.parseInt(smtpError.substring(0, 3)); // All retry-able SMTP errors should have codes starting // with 4 scheduleRetry(errorCode, messageContent); rescheduled = true; } catch (NumberFormatException nfe) { // smtpError didn't start with an error code, let's dig for // it String searchFor = "response:"; int rindex = smtpError.indexOf(searchFor); if (rindex > -1 && (rindex + searchFor.length()) < smtpError.length()) { int errorCode = Integer.parseInt( smtpError.substring(searchFor.length(), searchFor.length() + 3)); scheduleRetry(errorCode, messageContent); rescheduled = true; } } } if (rescheduled) { LOGGER.info("Email {} rescheduled for redelivery. ", nodePath); } else { LOGGER.error("Unable to reschedule email for delivery: " + e.getMessage(), e); } } } else { setError(messageContent, "Message must have a to and from set"); } } else { setError(messageContent, "Not an outbox"); } if (!messageContent.hasProperty(MessageConstants.PROP_SAKAI_MESSAGEERROR)) { messageContent.setProperty( MessageConstants.PROP_SAKAI_MESSAGEBOX, MessageConstants.BOX_SENT); } } } else { String retval = "null"; setError( messageContent, "Expected recipients to be String or List<String>. Found " + retval); } } finally { if (adminSession != null) { adminSession.logout(); } } } } catch (PathNotFoundException e) { LOGGER.error(e.getMessage(), e); } catch (RepositoryException e) { LOGGER.error(e.getMessage(), e); } catch (JMSException e) { LOGGER.error(e.getMessage(), e); } catch (EmailDeliveryException e) { LOGGER.error(e.getMessage()); } catch (ClientPoolException e) { LOGGER.error(e.getMessage(), e); } catch (StorageClientException e) { LOGGER.error(e.getMessage(), e); } catch (AccessDeniedException e) { LOGGER.error(e.getMessage(), e); } }
/** {@inheritDoc} */ @Override public void mapFrom(JMSBindingData source, Context context) throws Exception { super.mapFrom(source, context); Message message = source.getMessage(); // process JMS headers if (matches(HEADER_JMS_DESTINATION)) { context .setProperty(HEADER_JMS_DESTINATION, message.getJMSDestination()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_DELIVERY_MODE)) { context .setProperty(HEADER_JMS_DELIVERY_MODE, message.getJMSDeliveryMode()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_EXPIRATION)) { context .setProperty(HEADER_JMS_EXPIRATION, message.getJMSExpiration()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_PRIORITY)) { context .setProperty(HEADER_JMS_PRIORITY, message.getJMSPriority()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_MESSAGE_ID)) { context .setProperty(HEADER_JMS_MESSAGE_ID, message.getJMSMessageID()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_TIMESTAMP)) { context .setProperty(HEADER_JMS_TIMESTAMP, message.getJMSTimestamp()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_CORRELATION_ID)) { context .setProperty(HEADER_JMS_CORRELATION_ID, message.getJMSCorrelationID()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_REPLY_TO)) { context .setProperty(HEADER_JMS_REPLY_TO, message.getJMSReplyTo()) .addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_TYPE)) { context.setProperty(HEADER_JMS_TYPE, message.getJMSType()).addLabels(JMS_HEADER_LABELS); } if (matches(HEADER_JMS_REDELIVERED)) { context .setProperty(HEADER_JMS_REDELIVERED, message.getJMSRedelivered()) .addLabels(JMS_HEADER_LABELS); } // process JMS properties Enumeration<?> e = message.getPropertyNames(); while (e.hasMoreElements()) { String key = e.nextElement().toString(); if (matches(key)) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { context.setProperty(key, value).addLabels(JMS_PROPERTY_LABELS); } } else if (matches(key, getIncludeRegexes(), new ArrayList<Pattern>())) { Object value = null; try { value = message.getObjectProperty(key); } catch (JMSException pce) { // ignore and keep going (here just to keep checkstyle happy) pce.getMessage(); } if (value != null) { context.setProperty(key, value).addLabels(JMS_PROPERTY_LABELS); } } } }