@Override public boolean hasPayload() { return originalRequest.hasPayload(); }
@Override public boolean hasPayload() { return originalRequest.hasPayload(); }
@POST @Path("/store") public void store(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); StoreRequest storeRequest = createStoreRequest(topicId, request); // It must be transactional with payload for store request if (!storeRequest.isTransactional() || !storeRequest.hasPayload()) { throw new BadRequestException("Store request must be transactional with payload. Topic: " + topicId); } messagingService.storePayload(storeRequest); responder.sendStatus(HttpResponseStatus.OK); }
@POST @Path("/store") public void store(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); StoreRequest storeRequest = createStoreRequest(topicId, request); // It must be transactional with payload for store request if (!storeRequest.isTransactional() || !storeRequest.hasPayload()) { throw new BadRequestException("Store request must be transactional with payload. Topic: " + topicId); } messagingService.storePayload(storeRequest); responder.sendStatus(HttpResponseStatus.OK); }
@POST @Path("/publish") public void publish(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); StoreRequest storeRequest = createStoreRequest(topicId, request); // Empty payload is only allowed for transactional publish if (!storeRequest.isTransactional() && !storeRequest.hasPayload()) { throw new BadRequestException("Empty payload is only allowed for publishing transactional message. Topic: " + topicId); } // Publish the message and response with the rollback information RollbackDetail rollbackInfo = messagingService.publish(storeRequest); if (rollbackInfo == null) { // Non-tx publish doesn't have rollback info. responder.sendStatus(HttpResponseStatus.OK); return; } ByteBuf response = encodeRollbackDetail(rollbackInfo); responder.sendContent(HttpResponseStatus.OK, response, new DefaultHttpHeaders().set(HttpHeaderNames.CONTENT_TYPE, "avro/binary")); }
@POST @Path("/publish") public void publish(FullHttpRequest request, HttpResponder responder, @PathParam("namespace") String namespace, @PathParam("topic") String topic) throws Exception { TopicId topicId = new NamespaceId(namespace).topic(topic); StoreRequest storeRequest = createStoreRequest(topicId, request); // Empty payload is only allowed for transactional publish if (!storeRequest.isTransactional() && !storeRequest.hasPayload()) { throw new BadRequestException("Empty payload is only allowed for publishing transactional message. Topic: " + topicId); } // Publish the message and response with the rollback information RollbackDetail rollbackInfo = messagingService.publish(storeRequest); if (rollbackInfo == null) { // Non-tx publish doesn't have rollback info. responder.sendStatus(HttpResponseStatus.OK); return; } ByteBuf response = encodeRollbackDetail(rollbackInfo); responder.sendContent(HttpResponseStatus.OK, response, new DefaultHttpHeaders().set(HttpHeaderNames.CONTENT_TYPE, "avro/binary")); }