// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/domain/ProcessEvent.java
// @Data
// public class ProcessEvent {
// 
//     public enum EventType {
//         ProcessCreated, BillingInitiated, PaymentReceived;
//     }
// 
//     private final String processId;
//     private final EventType eventType;
//     private final JsonObject payload;
// 
//     private ProcessEvent(EventType eventType, JsonObject payload) {
//         this.processId = payload.getString("processId");
//         this.eventType = eventType;
//         this.payload = payload;
//     }
// 
//     public static ProcessEvent created(JsonObject payload) {
//         return new ProcessEvent(EventType.ProcessCreated, payload);
//     }
// 
//     public static ProcessEvent from(String eventTypeValue, JsonObject payload) {
//         EventType eventType = EventType.valueOf(eventTypeValue);
//         return new ProcessEvent(eventType, payload);
//     }
// }


import de.qaware.oss.cloud.service.process.domain.ProcessEvent;
import io.opentracing.Tracer;
import io.opentracing.contrib.jms.common.TracingMessageListener;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.json.Json;
import javax.json.JsonReader;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;

    @Inject
    private Event<ProcessEvent> processEvent;

    @Inject
    private Tracer tracer;

    @Override
    public void onMessage(Message message) {
        logger.log(Level.INFO, "Received inbound process event message {0}.", message);

        new TracingMessageListener(this::onTracedMessage, tracer).onMessage(message);
    }

    private String getBody(Message message) {
        String body = null;
        try {
            if (message instanceof TextMessage) {
                body = ((TextMessage) message).getText();
            }
        } catch (JMSException e) {
            logger.log(Level.WARNING, "Could not get message body.", e);
        }
        return body;
    }

    private String getEventType(Message message) {
        String eventType = null;
        try {
            eventType = message.getJMSType();
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/domain/ProcessEvent.java
// @Data
// public class ProcessEvent {
// 
//     public enum EventType {
//         ProcessCreated, BillingInitiated, PaymentReceived;
//     }
// 
//     private final String processId;
//     private final EventType eventType;
//     private final JsonObject payload;
// 
//     private ProcessEvent(EventType eventType, JsonObject payload) {
//         this.processId = payload.getString("processId");
//         this.eventType = eventType;
//         this.payload = payload;
//     }
// 
//     public static ProcessEvent created(JsonObject payload) {
//         return new ProcessEvent(EventType.ProcessCreated, payload);
//     }
// 
//     public static ProcessEvent from(String eventTypeValue, JsonObject payload) {
//         EventType eventType = EventType.valueOf(eventTypeValue);
//         return new ProcessEvent(eventType, payload);
//     }
// }


// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/boundary/ProcessEventMDB.java
import de.qaware.oss.cloud.service.process.domain.ProcessEvent;
import io.opentracing.Tracer;
import io.opentracing.contrib.jms.common.TracingMessageListener;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.json.Json;
import javax.json.JsonReader;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;


    @Inject
    private Event<ProcessEvent> processEvent;

    @Inject
    private Tracer tracer;

    @Override
    public void onMessage(Message message) {
        logger.log(Level.INFO, "Received inbound process event message {0}.", message);

        new TracingMessageListener(this::onTracedMessage, tracer).onMessage(message);
    }

    private String getBody(Message message) {
        String body = null;
        try {
            if (message instanceof TextMessage) {
                body = ((TextMessage) message).getText();
            }
        } catch (JMSException e) {
            logger.log(Level.WARNING, "Could not get message body.", e);
        }
        return body;
    }

    private String getEventType(Message message) {
        String eventType = null;
        try {
            eventType = message.getJMSType();
        } catch (JMSException e) {