use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method startMessage.
private Message<GraphQLMessage> startMessage(String operationId, String sessionId) {
SimpMessageHeaderAccessor headerAccessor = simpHeaderAccessor(mockWebSocketSession(sessionId));
Map<String, Object> json = new HashMap<>();
json.put("query", "{}");
json.put("variables", "{}");
GraphQLMessage payload = new GraphQLMessage(operationId, GraphQLMessageType.START, json);
return MessageBuilder.createMessage(payload, headerAccessor.getMessageHeaders());
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandlerTest method testHandleConnectionTerminateMessageCancelsSubscriber.
@Test
public void testHandleConnectionTerminateMessageCancelsSubscriber() {
// given
WebSocketSession session = mockWebSocketSession("sessionId");
Message<GraphQLMessage> message = createDisconnectMessage(session);
GraphQLBrokerChannelSubscriber subscriber = mock(GraphQLBrokerChannelSubscriber.class);
GraphQLBrokerSubscriptionRegistry registry = messageHandler.getGraphQLsubscriptionRegistry();
registry.subscribe("sessionId", "subscriptionId", subscriber);
// when
this.messageHandler.handleMessage(message);
// then
verify(subscriber).cancel();
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerChannelSubscriber method onComplete.
@Override
public void onComplete() {
log.info("Subscription complete: {}", subscriptionRef.get());
cancel();
GraphQLMessage operationMessage = new GraphQLMessage(operationMessageId, GraphQLMessageType.COMPLETE);
Message<?> responseMessage = MessageBuilder.createMessage(operationMessage, getMessageHeaders());
outboundChannel.send(responseMessage);
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandler method handleStopSubscription.
@Timed
protected final void handleStopSubscription(Message<GraphQLMessage> message) {
logger.info("handleStopSubscription for message " + message);
MessageHeaders headers = message.getHeaders();
String sessionId = SimpMessageHeaderAccessor.getSessionId(headers);
GraphQLMessage operationPayload = message.getPayload();
graphQLsubscriptionRegistry.unsubscribe(sessionId, operationPayload.getId(), (subscriber) -> {
subscriber.onComplete();
});
}
use of org.activiti.cloud.services.notifications.graphql.ws.api.GraphQLMessage in project activiti-cloud by Activiti.
the class GraphQLBrokerMessageHandler method handleConnectionInitMessage.
@Timed
protected final void handleConnectionInitMessage(Message<GraphQLMessage> message) {
GraphQLMessage operationPayload = message.getPayload();
GraphQLMessage connection_ack = new GraphQLMessage(operationPayload.getId(), GraphQLMessageType.CONNECTION_ACK);
MessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.getMutableAccessor(message);
Message<?> responseMessage = MessageBuilder.createMessage(connection_ack, headerAccessor.getMessageHeaders());
getClientOutboundChannel().send(responseMessage);
}
Aggregations