将IBM消息中心与IBM BPM集成

时间:2016-08-02 15:19:27

标签: ibm-cloud ibm-bpm message-hub

我正在关注来自github的消息中心java示例。我创建了自己的Kafka生产者版本,它在使用java主应用程序的J2Se env上运行良好。下面的代码段 -



String jasslocation = "C:\\HOME\\Technical\\bluemix\\git\\message-hub-samples\\java\\message-hub-kafka-ssl\\resources" + File.separator + "jaas.conf";
		System.setProperty(JAAS_CONFIG_PROPERTY, jasslocation);
		
		Properties props = new Properties();
        props.put("key.serializer","org.apache.kafka.common.serialization.ByteArraySerializer");
        props.put("value.serializer","org.apache.kafka.common.serialization.ByteArraySerializer");
        props.put("bootstrap.servers","kafka02-prod02.messagehub.services.eu-gb.bluemix.net:9093");
        props.put("acks","all");
     //   props.put("block.on.bu","true");
        props.put("batch.size","1");
        props.put("security.protocol","SASL_SSL");
        props.put("ssl.protocol","TLSv1.2");
        props.put("ssl.enabled.protocols","TLSv1.2");
        props.put("ssl.truststore.location","C:\\IBM\\BPM857\\java_1.7_64\\jre\\lib\\security\\cacerts");
        //props.put("ssl.truststore.location","C:\\IBM\\IID\\v8.5\\jdk\\jre\\lib\\security\\cacerts");
        
        props.put("ssl.truststore.password","changeit");
        props.put("ssl.truststore.type","JKS");
        props.put("ssl.endpoint.identification.algorithm","HTTPS");
        
        String topic="mytopic";
        String message="publish message to a topic";
        try {
        	
          KafkaProducer<byte[], byte[]> kafkaProducer;
          kafkaProducer = new KafkaProducer<byte[], byte[]>(props);
          ProducerRecord<byte[], byte[]> producerRecord = new ProducerRecord<byte[], byte[]>(topic,message.getBytes("UTF-8"));
         
          RecordMetadata recordMetadata = kafkaProducer.send(producerRecord).get();
          //getting RecordMetadata is possible to validate topic, partition and offset
          System.out.println("topic where message is published : " + recordMetadata.topic());
          System.out.println("partition where message is published : " + recordMetadata.partition());
          System.out.println("message offset # : " + recordMetadata.offset());
          kafkaProducer.close();
&#13;
&#13;
&#13;

kafka客户端版本 - 0.90

当我将此代码包装在J2EE MDB中并将其部署在BPM服务器上时。当MDB触发时,线程会一直等待send(): -

RecordMetadata recordMetadata = kafkaProducer.send(producerRecord).get();

并且在一段时间后超时。它不会抛出任何其他异常或错误。

我的问题是,为了从BPM内部使用kafka客户端api,我是否必须执行任何其他步骤,如ssl配置等。

请告知。

感谢。

0 个答案:

没有答案