PendingStoreRequest(StoreRequest originalRequest, TopicMetadata topicMetadata) { super(originalRequest.getTopicId(), originalRequest.isTransactional(), originalRequest.getTransactionWritePointer()); this.originalRequest = originalRequest; this.metadata = topicMetadata; }
PendingStoreRequest(StoreRequest originalRequest, TopicMetadata topicMetadata) { super(originalRequest.getTopicId(), originalRequest.isTransactional(), originalRequest.getTransactionWritePointer()); this.originalRequest = originalRequest; this.metadata = topicMetadata; }
@Nullable @Override public RollbackDetail publish(StoreRequest request) throws TopicNotFoundException, IOException { try { TopicMetadata metadata = topicCache.get(request.getTopicId()); if (request.isTransactional()) { ensureValidTxLifetime(request.getTransactionWritePointer()); } return messageTableWriterCache.get(request.getTopicId()).persist(request, metadata); } catch (ExecutionException e) { Throwable cause = Objects.firstNonNull(e.getCause(), e); Throwables.propagateIfPossible(cause, TopicNotFoundException.class, IOException.class); throw Throwables.propagate(e); } }
@Nullable @Override public RollbackDetail publish(StoreRequest request) throws TopicNotFoundException, IOException { try { TopicMetadata metadata = topicCache.get(request.getTopicId()); if (request.isTransactional()) { ensureValidTxLifetime(request.getTransactionWritePointer()); } return messageTableWriterCache.get(request.getTopicId()).persist(request, metadata); } catch (ExecutionException e) { Throwable cause = Objects.firstNonNull(e.getCause(), e); Throwables.propagateIfPossible(cause, TopicNotFoundException.class, IOException.class); throw Throwables.propagate(e); } }
@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")); }
boolean publish) throws IOException, TopicNotFoundException { GenericRecord record = new GenericData.Record(Schemas.V1.PublishRequest.SCHEMA); if (request.isTransactional()) { record.put("transactionWritePointer", request.getTransactionWritePointer());
boolean publish) throws IOException, TopicNotFoundException { GenericRecord record = new GenericData.Record(Schemas.V1.PublishRequest.SCHEMA); if (request.isTransactional()) { record.put("transactionWritePointer", request.getTransactionWritePointer());