Skip to content

Commit 4355935

Browse files
committed
feat(ticketing-eventing): init handler-core
1 parent dbdb095 commit 4355935

File tree

10 files changed

+504
-0
lines changed

10 files changed

+504
-0
lines changed

ticketing-eventing/handler-core/pom.xml

Lines changed: 394 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<FindBugsFilter>
3+
<Match>
4+
<Bug pattern="CRLF_INJECTION_LOGS"/>
5+
</Match>
6+
<Match>
7+
<Bug pattern="EI_EXPOSE_REP"/>
8+
</Match>
9+
<Match>
10+
<Bug pattern="EI_EXPOSE_REP2"/>
11+
</Match>
12+
</FindBugsFilter>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore;
2+
3+
import org.springframework.boot.autoconfigure.AutoConfiguration;
4+
import org.springframework.context.annotation.ComponentScan;
5+
6+
@AutoConfiguration
7+
@ComponentScan
8+
public class HandlerCoreAutoConfiguration {
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.adapter.in;
2+
3+
import de.muenchen.oss.dbs.ticketing.eventing.handlercore.application.port.in.EventHandlerInPort;
4+
import de.muenchen.oss.dbs.ticketing.eventing.handlercore.domain.model.Event;
5+
import java.util.function.Consumer;
6+
import lombok.RequiredArgsConstructor;
7+
import lombok.extern.slf4j.Slf4j;
8+
import org.springframework.context.annotation.Bean;
9+
import org.springframework.messaging.Message;
10+
import org.springframework.stereotype.Service;
11+
12+
@Service
13+
@RequiredArgsConstructor
14+
@Slf4j
15+
public class StreamingInAdapter {
16+
private final EventHandlerInPort eventHandlerInPort;
17+
18+
/**
19+
* Consumer for Zammad events sent via Kafka from the eventing-service.
20+
*
21+
* @return The consumer.
22+
*/
23+
@Bean
24+
public Consumer<Message<Event>> event() {
25+
return message -> {
26+
eventHandlerInPort.handleEvent(message.getPayload());
27+
};
28+
}
29+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.adapter.out.zammad;
2+
3+
import de.muenchen.oss.dbs.ticketing.eai.client.api.TicketsApi;
4+
import de.muenchen.oss.dbs.ticketing.eai.client.model.TicketInternal;
5+
import de.muenchen.oss.dbs.ticketing.eventing.handlercore.application.port.out.TicketingOutPort;
6+
import lombok.RequiredArgsConstructor;
7+
import org.springframework.stereotype.Service;
8+
import org.springframework.web.reactive.function.client.WebClientResponseException;
9+
10+
@Service
11+
@RequiredArgsConstructor
12+
public class ZammadAdapter implements TicketingOutPort {
13+
private final TicketsApi ticketsApi;
14+
15+
@Override
16+
public TicketInternal getTicket(final String ticketId) {
17+
try {
18+
return ticketsApi.getTicketByIdWithUser(ticketId, null, null, null).block();
19+
} catch (final WebClientResponseException e) {
20+
throw new ZammadApiException("Getting ticket with id %s failed".formatted(ticketId), e);
21+
}
22+
}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.adapter.out.zammad;
2+
3+
@SuppressWarnings("PMD.MissingSerialVersionUID")
4+
public class ZammadApiException extends RuntimeException {
5+
public ZammadApiException(final String message, final Throwable cause) {
6+
super(message, cause);
7+
}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.application.port.in;
2+
3+
import de.muenchen.oss.dbs.ticketing.eventing.handlercore.domain.model.Event;
4+
5+
public interface EventHandlerInPort {
6+
void handleEvent(Event event);
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.application.port.out;
2+
3+
import de.muenchen.oss.dbs.ticketing.eai.client.model.TicketInternal;
4+
5+
public interface TicketingOutPort {
6+
TicketInternal getTicket(String ticketId);
7+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package de.muenchen.oss.dbs.ticketing.eventing.handlercore.domain.model;
2+
3+
import jakarta.validation.constraints.NotBlank;
4+
5+
public record Event(
6+
@NotBlank String action,
7+
@NotBlank String ticket,
8+
String status,
9+
String statusId,
10+
String anliegenart,
11+
String lhmExtId
12+
// TODO additional payload or everything/partial as map?
13+
) {
14+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
de.muenchen.oss.dbs.ticketing.eventing.handlercore.HandlerCoreAutoConfiguration

0 commit comments

Comments
 (0)