Transportable transportable = new TransportableImpl( ackMessage ); transport.doSend( transportable );
/** * Processes an incoming message string and returns the response message * string. Message processing consists of parsing the message, finding an * appropriate Application and processing the message with it, and encoding * the response. Applications are chosen from among those registered using * <code>registerApplication</code>. The Parser is obtained from the * Connection associated with this Responder. */ protected String processMessage(String incomingMessageString) throws HL7Exception { Map<String, Object> metadata = new HashMap<String, Object>(); InetSocketAddress remoteSocketAddress = (InetSocketAddress) inboundSocket.getRemoteSocketAddress(); metadata.put(ApplicationRouter.METADATA_KEY_SENDING_IP, remoteSocketAddress.getAddress().getHostAddress()); metadata.put(ApplicationRouter.METADATA_KEY_SENDING_PORT, remoteSocketAddress.getPort()); Transportable response = apps.processMessage(new TransportableImpl(incomingMessageString, metadata)); return response.getMessage(); }
/** * Processes an incoming message string and returns the response message * string. Message processing consists of parsing the message, finding an * appropriate Application and processing the message with it, and encoding * the response. Applications are chosen from among those registered using * <code>registerApplication</code>. The Parser is obtained from the * Connection associated with this Responder. */ protected String processMessage(String incomingMessageString) throws HL7Exception { Map<String, Object> metadata = new HashMap<String, Object>(); InetSocketAddress remoteSocketAddress = (InetSocketAddress) inboundSocket.getRemoteSocketAddress(); metadata.put(ApplicationRouter.METADATA_KEY_SENDING_IP, remoteSocketAddress.getAddress().getHostAddress()); metadata.put(ApplicationRouter.METADATA_KEY_SENDING_PORT, remoteSocketAddress.getPort()); Transportable response = apps.processMessage(new TransportableImpl(incomingMessageString, metadata)); return response.getMessage(); }
/** * @see ca.uhn.hl7v2.protocol.ApplicationRouter#processMessage(ca.uhn.hl7v2.protocol.Transportable) */ public Transportable processMessage(Transportable theMessage) throws HL7Exception { String[] result = processMessage(theMessage.getMessage(), theMessage.getMetadata()); Transportable response = new TransportableImpl(result[0]); if (result[1] != null) { response.getMetadata().put(METADATA_KEY_MESSAGE_CHARSET, result[1]); } return response; }
/** * @see ca.uhn.hl7v2.protocol.ApplicationRouter#processMessage(ca.uhn.hl7v2.protocol.Transportable) */ public Transportable processMessage(Transportable theMessage) throws HL7Exception { String[] result = processMessage(theMessage.getMessage(), theMessage.getMetadata()); Transportable response = new TransportableImpl(result[0]); if (result[1] != null) { response.getMetadata().put(METADATA_KEY_MESSAGE_CHARSET, result[1]); } return response; }
/** * 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; }
/** * 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; }
return new TransportableImpl(response.toString());
/** * 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; }
/** * 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; }
return new TransportableImpl(response.toString());
/** * @see ca.uhn.hl7v2.protocol.impl.AbstractTransport#doReceive() */ public Transportable doReceive() throws TransportException { Transportable result = null; try { String message = myReader.getMessage(); if (message != null) { result = new TransportableImpl(message); } } catch (LLPException e) { throw new TransportException(e); } catch (IOException e) { throw new TransportException(e); } return result; }
/** * @see ca.uhn.hl7v2.protocol.impl.AbstractTransport#doReceive() */ public Transportable doReceive() throws TransportException { Transportable result = null; try { String message = myReader.getMessage(); if (message != null) { result = new TransportableImpl(message); } } catch (LLPException e) { throw new TransportException(e); } catch (IOException e) { throw new TransportException(e); } return result; }
private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, ErrorCode theErrorCode, String theDescription) throws HL7Exception { Segment header = ourParser.getCriticalResponseData(theMessage.getMessage()); Message dummy = header.getMessage(); // MSH header refers to dummy, but not the other way round! DeepCopy.copy(header, (Segment)dummy.get("MSH")); try { HL7Exception hl7e = new HL7Exception(theDescription, theErrorCode); AcknowledgmentCode code = theAckCode == null ? AcknowledgmentCode.CR : AcknowledgmentCode.valueOf(theAckCode); Message out = dummy.generateACK(code, hl7e); String originalEncoding = ourParser.getEncoding(theMessage.getMessage()); String ackText = ourParser.encode(out, originalEncoding); return new TransportableImpl(ackText); } catch (IOException e) { throw new HL7Exception(e); } }
private static Transportable makeAcceptAck(Transportable theMessage, String theAckCode, ErrorCode theErrorCode, String theDescription) throws HL7Exception { Segment header = ourParser.getCriticalResponseData(theMessage.getMessage()); Message dummy = header.getMessage(); // MSH header refers to dummy, but not the other way round! DeepCopy.copy(header, (Segment)dummy.get("MSH")); try { HL7Exception hl7e = new HL7Exception(theDescription, theErrorCode); AcknowledgmentCode code = theAckCode == null ? AcknowledgmentCode.CR : AcknowledgmentCode.valueOf(theAckCode); Message out = dummy.generateACK(code, hl7e); String originalEncoding = ourParser.getEncoding(theMessage.getMessage()); String ackText = ourParser.encode(out, originalEncoding); return new TransportableImpl(ackText); } catch (IOException e) { throw new HL7Exception(e); } }
/** * @see ca.uhn.hl7v2.protocol.Initiator#sendAndReceive(ca.uhn.hl7v2.model.Message) */ public Message sendAndReceive(Message theMessage) throws HL7Exception { Terser t = new Terser(theMessage); String appAckNeeded = t.get("/MSH-16"); String msgId = t.get("/MSH-10"); String messageText = getParser().encode(theMessage); Map<String, Object> metadata = getMetadata(theMessage); Transportable out = new TransportableImpl(messageText, metadata); if (needAck(appAckNeeded)) { myProcessor.reserve(msgId, getReceiveTimeout()); } myProcessor.send(out, getMaxRetries(), getRetryInterval()); Message in = null; if (needAck(appAckNeeded)) { Transportable received = myProcessor.receive(msgId, getReceiveTimeout()); if (received != null && received.getMessage() != null) { in = getParser().parse(received.getMessage()); } } return in; }
/** * @see ca.uhn.hl7v2.protocol.Initiator#sendAndReceive(ca.uhn.hl7v2.model.Message) */ public Message sendAndReceive(Message theMessage) throws HL7Exception { Terser t = new Terser(theMessage); String appAckNeeded = t.get("/MSH-16"); String msgId = t.get("/MSH-10"); String messageText = getParser().encode(theMessage); Map<String, Object> metadata = getMetadata(theMessage); Transportable out = new TransportableImpl(messageText, metadata); if (needAck(appAckNeeded)) { myProcessor.reserve(msgId, getReceiveTimeout()); } myProcessor.send(out, getMaxRetries(), getRetryInterval()); Message in = null; if (needAck(appAckNeeded)) { Transportable received = myProcessor.receive(msgId, getReceiveTimeout()); if (received != null && received.getMessage() != null) { in = getParser().parse(received.getMessage()); } } return in; }