Giriş
Şu satırı dahil ederiz
import javax.management.NotificationBroadcastSupport;
Örnek
Şu satırı dahil ederiz
import javax.management.Notification; import javax.management.NotificationListener;
Gönderen tarafta şöyle yaparız
Dinleyen tarafta şöyle yaparızString fileName = ...int sequenceNumber = ...;Notification notification = new Notification("QUEUE_ITEM_ADDED", mySource, sequenceNumber);notification.setUserData(fileName);notificationBroadcasterSupport.sendNotification(notification);
public class MyListener extends NotificationListener {@Overridepublic void handleNotification(Notification notification, Object handback) {Executor executor = Executors.newSingleThreadExecutor();switch (notification.getType())case "QUEUE_ITEM_ADDED": {final String fileName = (String) notification.getUserData();...break;}}
Hiç yorum yok:
Yorum Gönder