我有一个在websphere下运行的应用程序的两面,
双方都加入了一个群集
first.log:INFO 16:02:33.174 [ClusterPacing-akka.actor.default-dispatcher-4] Cluster(akka://ClusterPacing) - Cluster Node [akka.tcp://ClusterPacing@serverone:2531] - Leader is moving node [akka.tcp://ClusterPacing@serverone:2531] to [Up]
first.log:INFO 16:02:38.123 [ClusterPacing-akka.actor.default-dispatcher-2] Cluster(akka://ClusterPacing) - Cluster Node [akka.tcp://ClusterPacing@serverone:2531] - Leader is moving node [akka.tcp://ClusterPacing@serverone:2532] to [Up]
我为主题“ReportStatus”
创建了一个主题订阅者public void onReceive(Object message) {
log.info("Received message: " + message);
if (message instanceof SubscribeAck)
log.info("Subscribed to: " + ((SubscribeAck) message).subscribe().topic());
else if (message instanceof Report) {
BatchedItemExecutionReport report = (Report) message;
log.info("Received report: " + report + " from "
+ getSender());
} else {
unhandled(message);
}
}
成功从日志文件(first.log)
中看到INFO 16:02:31.665 [server.startup : 2] sample.app.App - created BatchPacer: Actor[akka://ClusterPacing/user/BatchPacer#-1219521740]
INFO 16:02:31.665 [ClusterPacing-akka.actor.default-dispatcher-4] listeners.pacing.BatchPacer - Subscribing to: ReportStatus
INFO 16:02:31.720 [ClusterPacing-akka.actor.default-dispatcher-4] listeners.pacing.BatchPacer - Received message: SubscribeAck(Subscribe(omsReportStatus,None,Actor[akka://ClusterPacing/user/BatchPacer#-1219521740]))
INFO 16:02:31.721 [ClusterPacing-akka.actor.default-dispatcher-4] listeners.pacing.BatchPacer - Subscribed to: ReportStatus
和出版商
public class ReportPublisher extends UntypedActor {
private static final Logger log = LoggerFactory.getLogger(ReportPublisher.class);
private ActorRef mediator = null;
private ActorSystem actorSystem = null;
int jobCounter = 0;
public ReportPublisher (ActorSystem actorSystem) {
this.actorSystem = actorSystem;
mediator = DistributedPubSubExtension.get(actorSystem).mediator();
}
public static Props props(final ActorSystem actorSystem) {
return Props.create(new Creator<ReportPublisher >() {
private static final long serialVersionUID = 1L;
@Override
public ReportPublisher create() throws Exception {
return new ReportPublisher(actorSystem);
}
});
}
@Override
public void onReceive(Object message) {
log.info("message: " + message);
if (message instanceof Report) {
Report report = (Report) message;
log.info("got: " + report);
publish(report);
} else {
unhandled(message);
}
}
void publish(Report report) {
log.info("Sending: " + report);
mediator.tell(new DistributedPubSubMediator.Publish(
REPORT_STATUS_TOPIC, report), getSelf());
log.info("Sent.");
}
}
当代码中的某个地方我打电话
reportPublisher.tell(report,null);
邮件会在second.log
中看到INFO 16:03:34.896 [ClusterPacing-akka.actor.default-dispatcher-4] oms.app.ReportPublisher - message: Report[Exception:null, ReportError:null, GatewayError:null, , id:15042002200380001]
INFO 16:03:34.896 [ClusterPacing-akka.actor.default-dispatcher-4] oms.app.ReportPublisher - got: Report[Exception:null, ReportError:null, GatewayError:null, , id:15042002200380001]
INFO 16:03:34.897 [ClusterPacing-akka.actor.default-dispatcher-4] oms.app.ReportPublisher - Sending: Report[Exception:null, ReportError:null, GatewayError:null, , id:15042002200380001]
INFO 16:03:34.897 [ClusterPacing-akka.actor.default-dispatcher-4] oms.app.ReportPublisher - Sent.
只有主题订阅者才收到它...
配置文件如下
akka {
loglevel = "DEBUG"
actor.debug.unhandled = on
extensions = ["akka.contrib.pattern.DistributedPubSubExtension"]
actor {
provider = "akka.cluster.ClusterActorRefProvider"
}
remote {
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = serverone
port = 0
}
}
cluster {
seed-nodes= [
"akka.tcp://ClusterPacing@serverone:2531",
"akka.tcp://ClusterPacing@serverone:2532"
]
}
}
再次,此代码在websphere中运行,因为两个独立的应用程序加入了相同的(现在是本地的)集群
我最初编写了一个独立的Java应用程序,只是为了确保代码正常工作,并且...它可以工作但不在Websphere中
我做错了什么?!?
由于