// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/BillingEventTopic.java
// @Stateless
// public class BillingEventTopic {
// 
//     @Inject
//     private Logger logger;
// 
//     @Resource(lookup = "jms/activeMqConnectionFactory")
//     private ConnectionFactory connectionFactory;
// 
//     @Resource(lookup = "jms/BillingEvents")
//     private Topic destination;
// 
//     @Inject
//     private Tracer tracer;
// 
//     public void publish(String eventType, JsonObject billingEvent) {
//         try (Connection connection = connectionFactory.createConnection()) {
//             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//             MessageProducer producer = new TracingMessageProducer(session.createProducer(destination), tracer);
//             // producer.setDeliveryDelay(1000);    // 1 second
//             producer.setTimeToLive(1000 * 300); // 5 minutes
// 
//             StringWriter payload = new StringWriter();
//             JsonWriter jsonWriter = Json.createWriter(payload);
//             jsonWriter.writeObject(billingEvent);
// 
//             TextMessage textMessage = session.createTextMessage(payload.toString());
//             textMessage.setJMSType(eventType);
//             textMessage.setStringProperty("contentType", "application/vnd.billing.v1+json");
// 
//             producer.send(textMessage);
//             logger.log(Level.INFO, "Sent {0} to BillingEvents destination.", textMessage);
//         } catch (JMSException e) {
//             logger.log(Level.WARNING, "Could not send JMS message.", e);
//         }
//     }
// }
// 
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/PaymentEventTopic.java
// @Stateless
// public class PaymentEventTopic {
// 
//     @Inject
//     private Logger logger;
// 
//     @Resource(lookup = "jms/activeMqConnectionFactory")
//     private ConnectionFactory connectionFactory;
// 
//     @Resource(lookup = "jms/PaymentEvents")
//     private Topic destination;
// 
//     @Inject
//     private Tracer tracer;
// 
//     public void publish(String eventType, JsonObject paymentEvent) {
//         try (Connection connection = connectionFactory.createConnection()) {
//             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//             MessageProducer producer = new TracingMessageProducer(session.createProducer(destination), tracer);
//             // producer.setDeliveryDelay(1000);    // 1 second
//             producer.setTimeToLive(1000 * 300); // 5 minutes
// 
//             StringWriter payload = new StringWriter();
//             JsonWriter jsonWriter = Json.createWriter(payload);
//             jsonWriter.writeObject(paymentEvent);
// 
//             TextMessage textMessage = session.createTextMessage(payload.toString());
//             textMessage.setJMSType(eventType);
//             textMessage.setStringProperty("contentType", "application/vnd.payment.v1+json");
// 
//             producer.send(textMessage);
//             logger.log(Level.INFO, "Sent {0} to BillingEvents destination.", textMessage);
//         } catch (JMSException e) {
//             logger.log(Level.WARNING, "Could not send JMS message.", e);
//         }
//     }
// }
// 
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/ProcessServiceConfig.java
// @Configuration(cacheFor = 60)
// public interface ProcessServiceConfig {
// 
//     @ConfigProperty(name = "service.name", defaultValue = "Process Service (Default)")
//     String serviceName();
// 
//     @ConfigProperty(name = "processing.seconds", defaultValue = "1")
//     int processingSeconds();
// 
// }


import de.qaware.oss.cloud.service.process.integration.BillingEventTopic;
import de.qaware.oss.cloud.service.process.integration.PaymentEventTopic;
import de.qaware.oss.cloud.service.process.integration.ProcessServiceConfig;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
package de.qaware.oss.cloud.service.process.domain;



/**
 * Handle the events for a post-payment process.
 */
@ApplicationScoped
public class PostPaymentHandler {

    @Inject
    private Logger logger;

    @Inject
    private ProcessServiceConfig config;

    @Inject
    private BillingEventTopic billingEventTopic;

    @Inject
    private PaymentEventTopic paymentEventTopic;

    public void observe(@Observes ProcessEvent processEvent) {
        ProcessEvent.EventType eventType = processEvent.getEventType();
        logger.log(Level.INFO, "{0} for {1}.", new Object[]{eventType, processEvent.getPayload()});

        switch (eventType) {
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/BillingEventTopic.java
// @Stateless
// public class BillingEventTopic {
// 
//     @Inject
//     private Logger logger;
// 
//     @Resource(lookup = "jms/activeMqConnectionFactory")
//     private ConnectionFactory connectionFactory;
// 
//     @Resource(lookup = "jms/BillingEvents")
//     private Topic destination;
// 
//     @Inject
//     private Tracer tracer;
// 
//     public void publish(String eventType, JsonObject billingEvent) {
//         try (Connection connection = connectionFactory.createConnection()) {
//             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//             MessageProducer producer = new TracingMessageProducer(session.createProducer(destination), tracer);
//             // producer.setDeliveryDelay(1000);    // 1 second
//             producer.setTimeToLive(1000 * 300); // 5 minutes
// 
//             StringWriter payload = new StringWriter();
//             JsonWriter jsonWriter = Json.createWriter(payload);
//             jsonWriter.writeObject(billingEvent);
// 
//             TextMessage textMessage = session.createTextMessage(payload.toString());
//             textMessage.setJMSType(eventType);
//             textMessage.setStringProperty("contentType", "application/vnd.billing.v1+json");
// 
//             producer.send(textMessage);
//             logger.log(Level.INFO, "Sent {0} to BillingEvents destination.", textMessage);
//         } catch (JMSException e) {
//             logger.log(Level.WARNING, "Could not send JMS message.", e);
//         }
//     }
// }
// 
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/PaymentEventTopic.java
// @Stateless
// public class PaymentEventTopic {
// 
//     @Inject
//     private Logger logger;
// 
//     @Resource(lookup = "jms/activeMqConnectionFactory")
//     private ConnectionFactory connectionFactory;
// 
//     @Resource(lookup = "jms/PaymentEvents")
//     private Topic destination;
// 
//     @Inject
//     private Tracer tracer;
// 
//     public void publish(String eventType, JsonObject paymentEvent) {
//         try (Connection connection = connectionFactory.createConnection()) {
//             Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//             MessageProducer producer = new TracingMessageProducer(session.createProducer(destination), tracer);
//             // producer.setDeliveryDelay(1000);    // 1 second
//             producer.setTimeToLive(1000 * 300); // 5 minutes
// 
//             StringWriter payload = new StringWriter();
//             JsonWriter jsonWriter = Json.createWriter(payload);
//             jsonWriter.writeObject(paymentEvent);
// 
//             TextMessage textMessage = session.createTextMessage(payload.toString());
//             textMessage.setJMSType(eventType);
//             textMessage.setStringProperty("contentType", "application/vnd.payment.v1+json");
// 
//             producer.send(textMessage);
//             logger.log(Level.INFO, "Sent {0} to BillingEvents destination.", textMessage);
//         } catch (JMSException e) {
//             logger.log(Level.WARNING, "Could not send JMS message.", e);
//         }
//     }
// }
// 
// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/integration/ProcessServiceConfig.java
// @Configuration(cacheFor = 60)
// public interface ProcessServiceConfig {
// 
//     @ConfigProperty(name = "service.name", defaultValue = "Process Service (Default)")
//     String serviceName();
// 
//     @ConfigProperty(name = "processing.seconds", defaultValue = "1")
//     int processingSeconds();
// 
// }


// Path: microservices/process-service/src/main/java/de/qaware/oss/cloud/service/process/domain/PostPaymentHandler.java
import de.qaware.oss.cloud.service.process.integration.BillingEventTopic;
import de.qaware.oss.cloud.service.process.integration.PaymentEventTopic;
import de.qaware.oss.cloud.service.process.integration.ProcessServiceConfig;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;

package de.qaware.oss.cloud.service.process.domain;



/**
 * Handle the events for a post-payment process.
 */
@ApplicationScoped
public class PostPaymentHandler {

    @Inject
    private Logger logger;

    @Inject
    private ProcessServiceConfig config;

    @Inject
    private BillingEventTopic billingEventTopic;

    @Inject
    private PaymentEventTopic paymentEventTopic;

    public void observe(@Observes ProcessEvent processEvent) {
        ProcessEvent.EventType eventType = processEvent.getEventType();
        logger.log(Level.INFO, "{0} for {1}.", new Object[]{eventType, processEvent.getPayload()});

        switch (eventType) {
            case ProcessCreated: