use of javax.jms.JMSException in project Protocol-Adapter-OSLP by OSGP.
the class TariffSwitchingGetStatusRequestMessageProcessor method processMessage.
@Override
public void processMessage(final ObjectMessage message) {
LOGGER.info("Processing tariff switching get status request message");
String correlationUid = null;
String domain = null;
String domainVersion = null;
String messageType = null;
String organisationIdentification = null;
String deviceIdentification = null;
String ipAddress = null;
int retryCount = 0;
boolean isScheduled = false;
try {
correlationUid = message.getJMSCorrelationID();
domain = message.getStringProperty(Constants.DOMAIN);
domainVersion = message.getStringProperty(Constants.DOMAIN_VERSION);
messageType = message.getJMSType();
organisationIdentification = message.getStringProperty(Constants.ORGANISATION_IDENTIFICATION);
deviceIdentification = message.getStringProperty(Constants.DEVICE_IDENTIFICATION);
ipAddress = message.getStringProperty(Constants.IP_ADDRESS);
retryCount = message.getIntProperty(Constants.RETRY_COUNT);
isScheduled = message.propertyExists(Constants.IS_SCHEDULED) ? message.getBooleanProperty(Constants.IS_SCHEDULED) : false;
} catch (final JMSException e) {
LOGGER.error("UNRECOVERABLE ERROR, unable to read ObjectMessage instance, giving up.", e);
LOGGER.debug("correlationUid: {}", correlationUid);
LOGGER.debug("domain: {}", domain);
LOGGER.debug("domainVersion: {}", domainVersion);
LOGGER.debug("messageType: {}", messageType);
LOGGER.debug("organisationIdentification: {}", organisationIdentification);
LOGGER.debug("deviceIdentification: {}", deviceIdentification);
LOGGER.debug("ipAddress: {}", ipAddress);
return;
}
LOGGER.info("Calling DeviceService function: {} for domain: {} {}", messageType, domain, domainVersion);
final GetStatusDeviceRequest deviceRequest = new GetStatusDeviceRequest(organisationIdentification, deviceIdentification, correlationUid, DomainTypeDto.TARIFF_SWITCHING, domain, domainVersion, messageType, ipAddress, retryCount, isScheduled);
this.deviceService.getStatus(deviceRequest);
}
use of javax.jms.JMSException in project ignite by apache.
the class IgniteJmsStreamerTest method produceObjectMessages.
private void produceObjectMessages(Destination dest, boolean singleMsg) throws JMSException {
Session ses = connFactory.createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer mp = ses.createProducer(dest);
HashSet<TestTransformers.TestObject> set = new HashSet<>();
for (String key : TEST_DATA.keySet()) {
TestTransformers.TestObject to = new TestTransformers.TestObject(key, TEST_DATA.get(key));
set.add(to);
}
int messagesSent;
if (singleMsg) {
mp.send(ses.createObjectMessage(set));
messagesSent = 1;
} else {
for (TestTransformers.TestObject to : set) mp.send(ses.createObjectMessage(to));
messagesSent = set.size();
}
if (dest instanceof Queue) {
try {
assertEquals(messagesSent, broker.getBroker().getDestinationMap().get(dest).getDestinationStatistics().getMessages().getCount());
} catch (Exception e) {
fail(e.toString());
}
}
}
use of javax.jms.JMSException in project ignite by apache.
the class IgniteJmsStreamerTest method produceStringMessages.
private void produceStringMessages(Destination dest, boolean singleMsg) throws JMSException {
Session ses = connFactory.createConnection().createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer mp = ses.createProducer(dest);
HashSet<String> set = new HashSet<>();
for (String key : TEST_DATA.keySet()) set.add(key + "," + TEST_DATA.get(key));
int messagesSent;
if (singleMsg) {
StringBuilder sb = new StringBuilder();
for (String s : set) sb.append(s).append("|");
sb.deleteCharAt(sb.length() - 1);
mp.send(ses.createTextMessage(sb.toString()));
messagesSent = 1;
} else {
for (String s : set) mp.send(ses.createTextMessage(s));
messagesSent = set.size();
}
if (dest instanceof Queue) {
try {
assertEquals(messagesSent, broker.getBroker().getDestinationMap().get(dest).getDestinationStatistics().getMessages().getCount());
} catch (Exception e) {
fail(e.toString());
}
}
}
use of javax.jms.JMSException in project hive by apache.
the class TestNotificationListener method onMessage.
@Override
public void onMessage(Message msg) {
String event;
try {
event = msg.getStringProperty(HCatConstants.HCAT_EVENT);
String format = msg.getStringProperty(HCatConstants.HCAT_MESSAGE_FORMAT);
String version = msg.getStringProperty(HCatConstants.HCAT_MESSAGE_VERSION);
String messageBody = ((TextMessage) msg).getText();
actualMessages.add(event);
MessageDeserializer deserializer = MessageFactory.getDeserializer(format, version);
if (event.equals(HCatConstants.HCAT_CREATE_DATABASE_EVENT)) {
Assert.assertEquals("topic://" + HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX, msg.getJMSDestination().toString());
CreateDatabaseMessage message = deserializer.getCreateDatabaseMessage(messageBody);
Assert.assertEquals("mydb", message.getDB());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof CreateDatabaseMessage);
Assert.assertEquals("mydb", message2.getDB());
} else if (event.equals(HCatConstants.HCAT_CREATE_TABLE_EVENT)) {
Assert.assertEquals("topic://hcat.mydb", msg.getJMSDestination().toString());
CreateTableMessage message = deserializer.getCreateTableMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof CreateTableMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((CreateTableMessage) message2).getTable());
} else if (event.equals(HCatConstants.HCAT_ADD_PARTITION_EVENT)) {
Assert.assertEquals("topic://hcat.mydb.mytbl", msg.getJMSDestination().toString());
AddPartitionMessage message = deserializer.getAddPartitionMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(1, message.getPartitions().size());
Assert.assertEquals("2011", message.getPartitions().get(0).get("b"));
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof AddPartitionMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((AddPartitionMessage) message2).getTable());
Assert.assertEquals(1, ((AddPartitionMessage) message2).getPartitions().size());
Assert.assertEquals("2011", ((AddPartitionMessage) message2).getPartitions().get(0).get("b"));
} else if (event.equals(HCatConstants.HCAT_ALTER_PARTITION_EVENT)) {
Assert.assertEquals("topic://hcat.mydb.mytbl", msg.getJMSDestination().toString());
// for alter partition events
AlterPartitionMessage message = deserializer.getAlterPartitionMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(1, message.getKeyValues().size());
Assert.assertTrue(message.getKeyValues().values().contains("2011"));
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof AlterPartitionMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((AlterPartitionMessage) message2).getTable());
Assert.assertEquals(1, ((AlterPartitionMessage) message2).getKeyValues().size());
Assert.assertTrue(((AlterPartitionMessage) message2).getKeyValues().values().contains("2011"));
} else if (event.equals(HCatConstants.HCAT_DROP_PARTITION_EVENT)) {
Assert.assertEquals("topic://hcat.mydb.mytbl", msg.getJMSDestination().toString());
DropPartitionMessage message = deserializer.getDropPartitionMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(1, message.getPartitions().size());
Assert.assertEquals("2011", message.getPartitions().get(0).get("b"));
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof DropPartitionMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((DropPartitionMessage) message2).getTable());
Assert.assertEquals(1, ((DropPartitionMessage) message2).getPartitions().size());
Assert.assertEquals("2011", ((DropPartitionMessage) message2).getPartitions().get(0).get("b"));
} else if (event.equals(HCatConstants.HCAT_DROP_TABLE_EVENT)) {
Assert.assertEquals("topic://hcat.mydb", msg.getJMSDestination().toString());
DropTableMessage message = deserializer.getDropTableMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof DropTableMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((DropTableMessage) message2).getTable());
} else if (event.equals(HCatConstants.HCAT_DROP_DATABASE_EVENT)) {
Assert.assertEquals("topic://" + HCatConstants.HCAT_DEFAULT_TOPIC_PREFIX, msg.getJMSDestination().toString());
DropDatabaseMessage message = deserializer.getDropDatabaseMessage(messageBody);
Assert.assertEquals("mydb", message.getDB());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof DropDatabaseMessage);
Assert.assertEquals("mydb", message2.getDB());
} else if (event.equals(HCatConstants.HCAT_ALTER_TABLE_EVENT)) {
Assert.assertEquals("topic://hcat.mydb", msg.getJMSDestination().toString());
AlterTableMessage message = deserializer.getAlterTableMessage(messageBody);
Assert.assertEquals("mytbl", message.getTable());
Assert.assertEquals("mydb", message.getDB());
Assert.assertEquals(TableType.MANAGED_TABLE.toString(), message.getTableType());
HCatEventMessage message2 = MessagingUtils.getMessage(msg);
Assert.assertTrue("Unexpected message-type.", message2 instanceof AlterTableMessage);
Assert.assertEquals("mydb", message2.getDB());
Assert.assertEquals("mytbl", ((AlterTableMessage) message2).getTable());
} else if (event.equals(HCatConstants.HCAT_PARTITION_DONE_EVENT)) {
// TODO: Fill in when PARTITION_DONE_EVENT is supported.
Assert.assertTrue("Unexpected: HCAT_PARTITION_DONE_EVENT not supported (yet).", false);
} else {
Assert.assertTrue("Unexpected event-type: " + event, false);
}
} catch (JMSException e) {
e.printStackTrace(System.err);
assert false;
} finally {
messageReceivedSignal.countDown();
}
}
use of javax.jms.JMSException in project hono by eclipse.
the class DeviceRegistrationIT method testOpenReceiverFailsForMalformedReplyToAddress.
/**
* Verifies that a client must use a correct <em>reply-to</em> address when opening a link for receiving registration responses.
*
* @throws Exception if the test fails.
*/
@Test
public void testOpenReceiverFailsForMalformedReplyToAddress() throws Exception {
// GIVEN a source address that does not contain a resourceId segment
final Destination invalidSource = new JmsQueue("registration/" + JmsIntegrationTestSupport.TEST_TENANT_ID);
// WHEN trying to open a receiver link using the malformed source address
try {
registration.createConsumerWithoutListener(invalidSource);
fail("Should have failed to create consumer");
} catch (JMSException e) {
// THEN the attempt fails
}
}
Aggregations