use of javax.jms.ObjectMessage in project Protocol-Adapter-OSLP by OSGP.
the class DeviceRequestMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
final ObjectMessage objectMessage = (ObjectMessage) message;
String messageType = null;
try {
messageType = message.getJMSType();
LOGGER.info("Received message of type: {}", messageType);
final MessageProcessor processor = this.oslpRequestMessageProcessorMap.getMessageProcessor(objectMessage);
processor.processMessage(objectMessage);
} catch (final JMSException ex) {
LOGGER.error("Unexpected JMSException during onMessage(Message)", ex);
this.sendException(objectMessage, ex, "JMSException while processing message");
} catch (final IllegalArgumentException e) {
LOGGER.error("Unexpected IllegalArgumentException during onMessage(Message)", e);
this.sendException(objectMessage, new NotSupportedException(ComponentType.PROTOCOL_OSLP, messageType), "Unsupported device function: " + messageType);
}
}
use of javax.jms.ObjectMessage in project Protocol-Adapter-OSLP by OSGP.
the class OsgpResponseMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
LOGGER.info("Received message of type: {}", message.getJMSType());
final ObjectMessage objectMessage = (ObjectMessage) message;
final String messageType = objectMessage.getJMSType();
final String deviceIdentifcation = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
final ResponseMessage responseMessage = (ResponseMessage) objectMessage.getObject();
final String result = responseMessage == null ? null : responseMessage.getResult().toString();
final OsgpException osgpException = responseMessage == null ? null : responseMessage.getOsgpException();
switch(DeviceFunctionDto.valueOf(messageType)) {
case REGISTER_DEVICE:
if (ResponseMessageResultType.valueOf(result).equals(ResponseMessageResultType.NOT_OK)) {
throw new ProtocolAdapterException(String.format("Response for device: %s for MessageType: %s is: %s, error: %s", deviceIdentifcation, messageType, result, osgpException));
}
break;
default:
throw new UnknownMessageTypeException("Unknown JMSType: " + messageType);
}
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
} catch (final ProtocolAdapterException e) {
LOGGER.error("ProtocolAdapterException", e);
} catch (final UnknownMessageTypeException e) {
LOGGER.error("UnknownMessageTypeException", e);
}
}
use of javax.jms.ObjectMessage in project Protocol-Adapter-OSLP by OSGP.
the class OslpLogItemRequestMessageSender method send.
public void send(final OslpLogItemRequestMessage oslpLogItemRequestMessage) {
LOGGER.debug("Sending OslpLogItemRequestMessage");
this.oslpLogItemRequestsJmsTemplate.send(new MessageCreator() {
@Override
public Message createMessage(final Session session) throws JMSException {
final ObjectMessage objectMessage = session.createObjectMessage();
objectMessage.setJMSType(Constants.OSLP_LOG_ITEM_REQUEST);
objectMessage.setStringProperty(Constants.IS_INCOMING, oslpLogItemRequestMessage.isIncoming().toString());
objectMessage.setStringProperty(Constants.DEVICE_UID, oslpLogItemRequestMessage.getDeviceUid());
objectMessage.setStringProperty(Constants.ENCODED_MESSAGE, oslpLogItemRequestMessage.getEncodedMessage());
objectMessage.setStringProperty(Constants.DECODED_MESSAGE, oslpLogItemRequestMessage.getDecodedMessage());
objectMessage.setStringProperty(Constants.DEVICE_IDENTIFICATION, oslpLogItemRequestMessage.getDeviceIdentification());
objectMessage.setStringProperty(Constants.ORGANISATION_IDENTIFICATION, oslpLogItemRequestMessage.getOrganisationIdentification());
objectMessage.setStringProperty(Constants.IS_VALID, oslpLogItemRequestMessage.isValid().toString());
objectMessage.setIntProperty(Constants.PAYLOAD_MESSAGE_SERIALIZED_SIZE, oslpLogItemRequestMessage.getPayloadMessageSerializedSize());
return objectMessage;
}
});
}
use of javax.jms.ObjectMessage in project Protocol-Adapter-OSLP by OSGP.
the class SigningServerRequestMessageListener method onMessage.
@Override
public void onMessage(final Message message) {
try {
final ObjectMessage objectMessage = (ObjectMessage) message;
final Destination replyToQueue = objectMessage.getJMSReplyTo();
final RequestMessage requestMessage = (RequestMessage) objectMessage.getObject();
final UnsignedOslpEnvelopeDto unsignedOslpEnvelopeDto = (UnsignedOslpEnvelopeDto) requestMessage.getRequest();
final String correlationUid = objectMessage.getJMSCorrelationID();
final String deviceIdentification = objectMessage.getStringProperty(Constants.DEVICE_IDENTIFICATION);
LOGGER.info("Received message of type: {}, for device: {} with correlationId: {} and replyToQueue: {}", objectMessage.getJMSType(), deviceIdentification, correlationUid, replyToQueue.toString());
LOGGER.debug("-----------------------------------------------------------------------------");
LOGGER.debug("unsignedOslpEnvelopeDto.getCorrelationUid() : {}", unsignedOslpEnvelopeDto.getCorrelationUid());
LOGGER.debug("unsignedOslpEnvelopeDto.getDeviceId() : {}", unsignedOslpEnvelopeDto.getDeviceId());
LOGGER.debug("unsignedOslpEnvelopeDto.getDomain() : {}", unsignedOslpEnvelopeDto.getDomain());
LOGGER.debug("unsignedOslpEnvelopeDto.getDomainVersion() : {}", unsignedOslpEnvelopeDto.getDomainVersion());
LOGGER.debug("unsignedOslpEnvelopeDto.getIpAddress() : {}", unsignedOslpEnvelopeDto.getIpAddress());
LOGGER.debug("unsignedOslpEnvelopeDto.getMessageType() : {}", unsignedOslpEnvelopeDto.getMessageType());
LOGGER.debug("unsignedOslpEnvelopeDto.getOrganisationIdentification() : {}", unsignedOslpEnvelopeDto.getOrganisationIdentification());
LOGGER.debug("unsignedOslpEnvelopeDto.getPayloadMessage() : {}", unsignedOslpEnvelopeDto.getPayloadMessage().toString());
LOGGER.debug("unsignedOslpEnvelopeDto.getRetryCount() : {}", unsignedOslpEnvelopeDto.getRetryCount());
LOGGER.debug("unsignedOslpEnvelopeDto.getSequenceNumber() : {}", unsignedOslpEnvelopeDto.getSequenceNumber());
LOGGER.debug("unsignedOslpEnvelopeDto.isScheduled() : {}", unsignedOslpEnvelopeDto.isScheduled());
LOGGER.debug("-----------------------------------------------------------------------------");
this.signingService.sign(unsignedOslpEnvelopeDto, correlationUid, deviceIdentification, replyToQueue);
} catch (final JMSException ex) {
LOGGER.error("Exception: {} ", ex.getMessage(), ex);
}
}
use of javax.jms.ObjectMessage in project cayenne by apache.
the class JMSBridge method onMessage.
/**
* JMS MessageListener implementation. Injects received events to the EventManager
* local event queue.
*/
public void onMessage(Message message) {
try {
Object vmID = message.getObjectProperty(JMSBridge.VM_ID_PROPERTY);
if (JMSBridge.VM_ID.equals(vmID)) {
return;
}
if (!(message instanceof ObjectMessage)) {
return;
}
ObjectMessage objectMessage = (ObjectMessage) message;
CayenneEvent event = messageObjectToEvent(objectMessage.getObject());
if (event != null) {
onExternalEvent(event);
}
} catch (MessageFormatException mfex) {
// TODO: Andrus, 2/8/2006 logging... Log4J was removed to make this usable on
// the client
} catch (Exception ex) {
// TODO: Andrus, 2/8/2006 logging... Log4J was removed to make this usable on
// the client
}
}
Aggregations