Commit e45ed0aa authored by David Dupplaw's avatar David Dupplaw

feat: DD: Update to pass in ActiveMQ host

parent 1057f561
......@@ -2,4 +2,5 @@ FROM java:8-jre
COPY . /usr/src/myapp
WORKDIR /usr/src/myapp
CMD ["java", "-jar", "target/service-under-test-1.0.0.jar"]
\ No newline at end of file
ENTRYPOINT ["java", "-jar", "target/service-under-test-1.0.0.jar"]
CMD ["localhost"]
\ No newline at end of file
package uk.me.dupplaw.david.integration;
import org.apache.activemq.command.ActiveMQMapMessage;
import javax.jms.*;
public class MessageHandler implements MessageListener {
......@@ -15,7 +17,13 @@ public class MessageHandler implements MessageListener {
public void onMessage(Message message) {
try {
System.out.println(" - Got message: "+message );
TextMessage newMessage = session.createTextMessage("Message was: "+message.getStringProperty("message"));
String text = message.getStringProperty("message");
if( message instanceof ActiveMQMapMessage ) {
text = ((ActiveMQMapMessage) message).getString("message");
}
TextMessage newMessage = session.createTextMessage("Message was: "+text );
producer.send(newMessage);
} catch (JMSException e) {
e.printStackTrace();
......
package uk.me.dupplaw.david.integration;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import javax.jms.*;
......@@ -9,10 +7,16 @@ import javax.jms.*;
public class ServiceUnderTest
{
public static void main(String[] args) throws JMSException, InterruptedException {
final ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
String hostName = "localhost";
if( args.length > 0 ) {
hostName = args[0];
}
final ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("failover://tcp://"+hostName+":61616");
final Connection connection = connectionFactory.createConnection();
System.out.println("Connecting to ActiveMQ...");
System.out.println("Connecting to ActiveMQ at tcp://"+hostName+":61616...");
connection.start();
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment