@Test void testSerializeRequest() { QueryMessage<String, Integer> message = new GenericQueryMessage<>("Test", "MyQueryName", instanceOf(int.class)); QueryRequest queryRequest = testSubject.serializeRequest(message, 5, 10, 1); QueryMessage<Object, Object> deserialized = testSubject.deserializeRequest(queryRequest); assertEquals(message.getIdentifier(), deserialized.getIdentifier()); assertEquals(message.getQueryName(), deserialized.getQueryName()); assertEquals(message.getMetaData(), deserialized.getMetaData()); assertTrue(message.getResponseType().matches(deserialized.getResponseType().responseMessagePayloadType())); assertEquals(message.getPayload(), deserialized.getPayload()); assertEquals(message.getPayloadType(), deserialized.getPayloadType()); }
public <Q, R> QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) { return QueryRequest.newBuilder() .setTimestamp(System.currentTimeMillis()) .setMessageIdentifier(queryMessage.getIdentifier()) .setQuery(queryMessage.getQueryName()) .setClientId(configuration.getClientId()) .setComponentName(configuration.getComponentName()) .setResponseType(responseTypeSerializer.apply( queryMessage.getResponseType().forSerialization() )) .setPayload(payloadSerializer.apply(queryMessage)) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.NR_OF_RESULTS) .setValue(MetaDataValue.newBuilder().setNumberValue(nrResults)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.TIMEOUT) .setValue(MetaDataValue.newBuilder().setNumberValue(timeout)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.PRIORITY) .setValue(MetaDataValue.newBuilder().setNumberValue(priority)) ) .putAllMetaData(metadataSerializer.apply(queryMessage.getMetaData())) .build(); }
QuerySerializer { public <Q, R> QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) { return QueryRequest.newBuilder() .setTimestamp(System.currentTimeMillis()) .setMessageIdentifier(queryMessage.getIdentifier()) .setQuery(queryMessage.getQueryName()) .setClientId(configuration.getClientId()) .setComponentName(configuration.getComponentName()) .setResponseType(responseTypeSerializer.apply( queryMessage.getResponseType().forSerialization() )) .setPayload(payloadSerializer.apply(queryMessage)) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.NR_OF_RESULTS) .setValue(MetaDataValue.newBuilder().setNumberValue(nrResults)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.TIMEOUT) .setValue(MetaDataValue.newBuilder().setNumberValue(timeout)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.PRIORITY) .setValue(MetaDataValue.newBuilder().setNumberValue(priority)) ) .putAllMetaData(metadataSerializer.apply(queryMessage.getMetaData())) .build(); } }
QuerySerializer { public <Q, R> QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) { return QueryRequest.newBuilder() .setTimestamp(System.currentTimeMillis()) .setMessageIdentifier(queryMessage.getIdentifier()) .setQuery(queryMessage.getQueryName()) .setClientId(configuration.getClientId()) .setComponentName(configuration.getComponentName()) .setResponseType(responseTypeSerializer.apply( queryMessage.getResponseType().forSerialization() )) .setPayload(payloadSerializer.apply(queryMessage)) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.NR_OF_RESULTS) .setValue(MetaDataValue.newBuilder().setNumberValue(nrResults)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.TIMEOUT) .setValue(MetaDataValue.newBuilder().setNumberValue(timeout)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.PRIORITY) .setValue(MetaDataValue.newBuilder().setNumberValue(priority)) ) .putAllMetaData(metadataSerializer.apply(queryMessage.getMetaData())) .build(); } QuerySerializer(Serializer messageSerializer,
                           Serializer serializer,
                           AxonServerConfiguration configuration); }
QuerySerializer { public <Q, R> QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) { return QueryRequest.newBuilder() .setTimestamp(System.currentTimeMillis()) .setMessageIdentifier(queryMessage.getIdentifier()) .setQuery(queryMessage.getQueryName()) .setClientId(configuration.getClientId()) .setComponentName(configuration.getComponentName()) .setResponseType(responseTypeSerializer.apply( queryMessage.getResponseType().forSerialization() )) .setPayload(payloadSerializer.apply(queryMessage)) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.NR_OF_RESULTS) .setValue(MetaDataValue.newBuilder().setNumberValue(nrResults)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.TIMEOUT) .setValue(MetaDataValue.newBuilder().setNumberValue(timeout)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.PRIORITY) .setValue(MetaDataValue.newBuilder().setNumberValue(priority)) ) .putAllMetaData(metadataSerializer.apply(queryMessage.getMetaData())) .build(); } QuerySerializer(Serializer messageSerializer,
                           Serializer serializer,
                           AxonServerConfiguration configuration); QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage,
                                                int nrResults,
                                                long timeout,
                                                int priority); QueryResponse serializeResponse(QueryResponseMessage<?> queryResponse, String requestMessageId); QueryMessage<Q, R> deserializeRequest(QueryRequest queryRequest); QueryResponseMessage<R> deserializeResponse(QueryResponse queryResponse,
                                                           ResponseType<R> expectedResponseType); }
QuerySerializer { public <Q, R> QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage, int nrResults, long timeout, int priority) { return QueryRequest.newBuilder() .setTimestamp(System.currentTimeMillis()) .setMessageIdentifier(queryMessage.getIdentifier()) .setQuery(queryMessage.getQueryName()) .setClientId(configuration.getClientId()) .setComponentName(configuration.getComponentName()) .setResponseType(responseTypeSerializer.apply( queryMessage.getResponseType().forSerialization() )) .setPayload(payloadSerializer.apply(queryMessage)) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.NR_OF_RESULTS) .setValue(MetaDataValue.newBuilder().setNumberValue(nrResults)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.TIMEOUT) .setValue(MetaDataValue.newBuilder().setNumberValue(timeout)) ) .addProcessingInstructions( ProcessingInstruction.newBuilder() .setKey(ProcessingKey.PRIORITY) .setValue(MetaDataValue.newBuilder().setNumberValue(priority)) ) .putAllMetaData(metadataSerializer.apply(queryMessage.getMetaData())) .build(); } QuerySerializer(Serializer messageSerializer,
                           Serializer serializer,
                           AxonServerConfiguration configuration); QueryRequest serializeRequest(QueryMessage<Q, R> queryMessage,
                                                int nrResults,
                                                long timeout,
                                                int priority); QueryResponse serializeResponse(QueryResponseMessage<?> queryResponse, String requestMessageId); QueryMessage<Q, R> deserializeRequest(QueryRequest queryRequest); QueryResponseMessage<R> deserializeResponse(QueryResponse queryResponse,
                                                           ResponseType<R> expectedResponseType);  }