/** * @param theConnection JMS connection over which messages are exchanged * @param theDestination JMS destination to which messages are produced and * from which messages are consumed */ public AbstractJMSTransport() { myMetadata = makeMetadata(); }
/** * @see ca.uhn.hl7v2.protocol.AbstractTransport#doReceive() */ public Transportable doReceive() throws TransportException { Transportable result = null; try { Message message = receiveJMS(); result = toTransportable(message); } catch (JMSException e) { throw new TransportException(e); } return result; }
/** * Sets common metadata on the basis of connection and destination. */ private Map<String, Object> makeMetadata() { Map<String, Object> md = new HashMap<String, Object>(); try { md.put(CLIENT_ID_KEY, getConnection().getClientID()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } try { md.put(CONNECTION_METADATA_KEY, getConnection().getMetaData()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } try { md.put(DESTINATION_NAME_KEY, getDestinationName()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } return md; }
/** * Copies data from the given Message into a Transportable. The default * implementation expects a TextMessage, but this can be overridden. * * @param theMessage a JMS Message from which to obtain data * @return a Transportable containing data from the given Message */ protected Transportable toTransportable(Message theMessage) throws TransportException { if ( !(theMessage instanceof TextMessage)) { throw new TransportException("This implementation expects getMessage() to return " + " a TextMessage. Override this method if another message type is to be used"); } Transportable result = null; try { String text = ((TextMessage) theMessage).getText(); result = new TransportableImpl(text); result.getMetadata().putAll(getCommonMetadata()); } catch (JMSException e) { throw new TransportException(e); } return result; }
Message message; try { message = getMessage();
/** * Sets common metadata on the basis of connection and destination. */ private Map<String, Object> makeMetadata() { Map<String, Object> md = new HashMap<String, Object>(); try { md.put(CLIENT_ID_KEY, getConnection().getClientID()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } try { md.put(CONNECTION_METADATA_KEY, getConnection().getMetaData()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } try { md.put(DESTINATION_NAME_KEY, getDestinationName()); } catch (JMSException e) { log.error("Error setting JMSTransport metadata", e); } return md; }
/** * Copies data from the given Message into a Transportable. The default * implementation expects a TextMessage, but this can be overridden. * * @param theMessage a JMS Message from which to obtain data * @return a Transportable containing data from the given Message */ protected Transportable toTransportable(Message theMessage) throws TransportException { if ( !(theMessage instanceof TextMessage)) { throw new TransportException("This implementation expects getMessage() to return " + " a TextMessage. Override this method if another message type is to be used"); } Transportable result = null; try { String text = ((TextMessage) theMessage).getText(); result = new TransportableImpl(text); result.getMetadata().putAll(getCommonMetadata()); } catch (JMSException e) { throw new TransportException(e); } return result; }
Message message; try { message = getMessage();
/** * @see ca.uhn.hl7v2.protocol.AbstractTransport#doReceive() */ public Transportable doReceive() throws TransportException { Transportable result = null; try { Message message = receiveJMS(); result = toTransportable(message); } catch (JMSException e) { throw new TransportException(e); } return result; }
/** * @param theConnection JMS connection over which messages are exchanged * @param theDestination JMS destination to which messages are produced and * from which messages are consumed */ public AbstractJMSTransport() { myMetadata = makeMetadata(); }