Как получить сообщение JSON из очереди Solace JMS, очередь уже созданаJAVA

Программисты JAVA общаются здесь
Anonymous
Как получить сообщение JSON из очереди Solace JMS, очередь уже создана

Сообщение Anonymous »

Я пытаюсь получить сообщения JSON из очереди Solace JMS, но не получаю никаких сообщений. Ниже мой код

Код: Выделить всё

@Service
public class QueueConsumer {

final String QUEUE_NAME = "test.Request.Q.V01";

// Latch used for synchronizing between threads
final CountDownLatch latch = new CountDownLatch(1);

public void run(String... args) throws Exception {

String host = "test.solace.com";
String vpnName = "TEST_VPN";
String username = "testVpn";
String password = "test123";

System.out.printf("QueueConsumer is connecting to Solace messaging at %s...%n", host);

SolConnectionFactory connectionFactory = SolJmsUtility.createConnectionFactory();
connectionFactory.setHost(host);
connectionFactory.setVPN(vpnName);
connectionFactory.setUsername(username);
connectionFactory.setPassword(password);

connectionFactory.setDynamicDurables(true);

Connection connection = connectionFactory.createConnection();

Session session = connection.createSession(false, SupportedProperty.SOL_CLIENT_ACKNOWLEDGE);

System.out.printf("Connected to the Solace Message VPN '%s' with client username '%s'.%n", vpnName, username);

Queue queue = session.createQueue(QUEUE_NAME);

MessageConsumer messageConsumer = session.createConsumer(queue);

messageConsumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
try {
if (message instanceof SolaceMsg) {
System.out.printf("TextMessage received: '%s'%n", ((SolaceMsg) message).getClass());
} else {
System.out.println("Message received.");
}
System.out.printf("Message Content:%n%s%n", SolJmsUtility.dumpMessage(message));

message.acknowledge();

latch.countDown(); // unblock the main thread
} catch (JMSException ex) {
System.out.println("Error processing incoming message.");
ex.printStackTrace();
}
}
});

System.out.println("Start receiving messages....");
connection.start();
System.out.println("Awaiting message...");
latch.await();

connection.stop();
messageConsumer.close();
session.close();
connection.close();
}

public static void main(String... args) throws Exception {
new QueueConsumer().run(args);
}
}
Моим типом сообщения является объявление JSON, указанное ниже, и для этого я создал POJO.

Код: Выделить всё

  {
"customerDetails": {
"customerID": "0001234",
"customerName": "John"
}
}
Я получаю одно предупреждение о том, что ответ — Очередь 400 уже существует, поскольку это существующая очередь, и я не получаю никаких сообщений. Что я здесь делаю не так?

Вернуться в «JAVA»