@Test public void testPublishGroupIdIsNotNum() { try { this.iProducer.publish(new WeEvent(this.topicName, "this is only test message".getBytes()), "sfsdf"); Assert.fail(); } catch (BrokerException e) { Assert.assertEquals(ErrorCode.WEB3SDK_UNKNOWN_GROUP.getCode(), e.getCode()); } }
@Override public CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr) throws BrokerException { log.debug("publish {} groupId: {}", event, groupIdStr); String groupId = selectGroupId(groupIdStr); this.validateGroupId(groupId); ParamCheckUtils.validateEvent(event); if (event.getExtensions().containsKey(WeEvent.WeEvent_SIGN)) { return fiscoBcosDelegate.sendRawTransaction(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8)); } else { if (event.getExtensions().containsKey(WeEvent.WeEvent_EPHEMERAL)) { log.info("ephemeral event"); return fiscoBcosDelegate.sendAMOP(event.getTopic(), Long.parseLong(groupId), JsonHelper.object2Json(event)); } else { return fiscoBcosDelegate.publishEvent(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8), JsonHelper.object2Json(event.getExtensions())); } } }
FiscoBcosBroker4Producer extends FiscoBcosTopicAdmin implements IProducer { @Override public CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr) throws BrokerException { log.debug("publish {} groupId: {}", event, groupIdStr); String groupId = selectGroupId(groupIdStr); this.validateGroupId(groupId); ParamCheckUtils.validateEvent(event); if (event.getExtensions().containsKey(WeEvent.WeEvent_SIGN)) { return fiscoBcosDelegate.sendRawTransaction(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8)); } else { if (event.getExtensions().containsKey(WeEvent.WeEvent_EPHEMERAL)) { log.info("ephemeral event"); return fiscoBcosDelegate.sendAMOP(event.getTopic(), Long.parseLong(groupId), JsonHelper.object2Json(event)); } else { return fiscoBcosDelegate.publishEvent(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8), JsonHelper.object2Json(event.getExtensions())); } } } }
FiscoBcosBroker4Producer extends FiscoBcosTopicAdmin implements IProducer { @Override public CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr) throws BrokerException { log.debug("publish {} groupId: {}", event, groupIdStr); String groupId = selectGroupId(groupIdStr); this.validateGroupId(groupId); ParamCheckUtils.validateEvent(event); if (event.getExtensions().containsKey(WeEvent.WeEvent_SIGN)) { return fiscoBcosDelegate.sendRawTransaction(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8)); } else { if (event.getExtensions().containsKey(WeEvent.WeEvent_EPHEMERAL)) { log.info("ephemeral event"); return fiscoBcosDelegate.sendAMOP(event.getTopic(), Long.parseLong(groupId), JsonHelper.object2Json(event)); } else { return fiscoBcosDelegate.publishEvent(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8), JsonHelper.object2Json(event.getExtensions())); } } } FiscoBcosBroker4Producer(FiscoBcosDelegate fiscoBcosDelegate); }
FiscoBcosBroker4Producer extends FiscoBcosTopicAdmin implements IProducer { @Override public CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr) throws BrokerException { log.debug("publish {} groupId: {}", event, groupIdStr); String groupId = selectGroupId(groupIdStr); this.validateGroupId(groupId); ParamCheckUtils.validateEvent(event); if (event.getExtensions().containsKey(WeEvent.WeEvent_SIGN)) { return fiscoBcosDelegate.sendRawTransaction(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8)); } else { if (event.getExtensions().containsKey(WeEvent.WeEvent_EPHEMERAL)) { log.info("ephemeral event"); return fiscoBcosDelegate.sendAMOP(event.getTopic(), Long.parseLong(groupId), JsonHelper.object2Json(event)); } else { return fiscoBcosDelegate.publishEvent(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8), JsonHelper.object2Json(event.getExtensions())); } } } FiscoBcosBroker4Producer(FiscoBcosDelegate fiscoBcosDelegate); @Override boolean startProducer(); @Override boolean shutdownProducer(); @Override CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr); }
FiscoBcosBroker4Producer extends FiscoBcosTopicAdmin implements IProducer { @Override public CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr) throws BrokerException { log.debug("publish {} groupId: {}", event, groupIdStr); String groupId = selectGroupId(groupIdStr); this.validateGroupId(groupId); ParamCheckUtils.validateEvent(event); if (event.getExtensions().containsKey(WeEvent.WeEvent_SIGN)) { return fiscoBcosDelegate.sendRawTransaction(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8)); } else { if (event.getExtensions().containsKey(WeEvent.WeEvent_EPHEMERAL)) { log.info("ephemeral event"); return fiscoBcosDelegate.sendAMOP(event.getTopic(), Long.parseLong(groupId), JsonHelper.object2Json(event)); } else { return fiscoBcosDelegate.publishEvent(event.getTopic(), Long.parseLong(groupId), new String(event.getContent(), StandardCharsets.UTF_8), JsonHelper.object2Json(event.getExtensions())); } } } FiscoBcosBroker4Producer(FiscoBcosDelegate fiscoBcosDelegate); @Override boolean startProducer(); @Override boolean shutdownProducer(); @Override CompletableFuture<SendResult> publish(WeEvent event, String groupIdStr);  }