Search in sources :

Example 11 with ChannelRequest

use of org.fisco.bcos.channel.dto.ChannelRequest in project web3sdk by FISCO-BCOS.

the class Channel2ClientNeedVerify method main.

public static void main(String[] args) throws Exception {
    if (args.length < parameterNum) {
        System.out.println("param: target topic total number of request");
        return;
    }
    String topic = args[0];
    Integer count = Integer.parseInt(args[1]);
    DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
    logger.debug("init client");
    ApplicationContext context = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");
    Service service = context.getBean(Service.class);
    service.run();
    System.out.println("3s ...");
    Thread.sleep(1000);
    System.out.println("2s ...");
    Thread.sleep(1000);
    System.out.println("1s ...");
    Thread.sleep(1000);
    System.out.println("start test");
    System.out.println("===================================================================");
    ChannelRequest request = new ChannelRequest();
    for (Integer i = 0; i < count; ++i) {
        Thread.sleep(2000);
        request.setToTopic(topic);
        request.setMessageID(service.newSeq());
        request.setTimeout(5000);
        String content = "request seq:" + request.getMessageID();
        request.setContent(content.getBytes());
        System.out.println(df.format(LocalDateTime.now()) + " request seq:" + request.getMessageID() + ", Content:" + request.getContent() + " content:" + Arrays.toString(request.getContentByteArray()));
        ChannelResponse response = service.sendChannelMessageForVerifyTopic(request);
        System.out.println(df.format(LocalDateTime.now()) + "response seq:" + response.getMessageID() + ", ErrorCode:" + response.getErrorCode() + ", Content:" + response.getContent());
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ChannelRequest(org.fisco.bcos.channel.dto.ChannelRequest) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Service(org.fisco.bcos.channel.client.Service) ChannelResponse(org.fisco.bcos.channel.dto.ChannelResponse) DateTimeFormatter(java.time.format.DateTimeFormatter)

Aggregations

ChannelRequest (org.fisco.bcos.channel.dto.ChannelRequest)11 DateTimeFormatter (java.time.format.DateTimeFormatter)8 Service (org.fisco.bcos.channel.client.Service)8 ApplicationContext (org.springframework.context.ApplicationContext)8 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 ChannelResponse (org.fisco.bcos.channel.dto.ChannelResponse)6 IOException (java.io.IOException)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 CertificateException (java.security.cert.CertificateException)1 InvalidKeySpecException (java.security.spec.InvalidKeySpecException)1 EventLogFilterPushResponse (org.fisco.bcos.channel.event.filter.EventLogFilterPushResponse)1 EventLogPushCallback (org.fisco.bcos.channel.event.filter.EventLogPushCallback)1 EventLogRequestParams (org.fisco.bcos.channel.event.filter.EventLogRequestParams)1 NodeRequestSdkVerifyTopic (org.fisco.bcos.channel.protocol.NodeRequestSdkVerifyTopic)1 SdkRequestNodeUpdateTopicStatus (org.fisco.bcos.channel.protocol.SdkRequestNodeUpdateTopicStatus)1