姚博文 postgresql listen/notify push message
来源:互联网 发布:jquery 1.4min.js下载 编辑:程序博客网 时间:2024/06/05 11:50
使用postgresql向客端推送消息
#listen message_channel;
notify message_channel,'hello todd';
jdbc:
Statement stmt = conn.createStatement();
stmt.execute("LISTEN message_channel");
stmt.close();
notifications = conn.getNotifications();
if (notifications != null && notifications.length > 0) {
for( final Session session: sessions ) {
for (int i=0; i<notifications.length; i++) {
// System.out.println("Got notification: " + notifications[i].getName());
// System.out.println("Got notification: " + notifications[i].getParameter());
// System.out.println("Got notification: " + notifications[i].getPID());
try {
session.getBasicRemote().sendObject(notifications[i].getParameter());
logger.debug("发送了消息(" + session.getId() + "):" + notifications[i].getParameter());
} catch (Exception e) {
logger.error("session(" + ((session != null)?session.getId():"") + ")发送失败:" + e.getMessage());
continue;
}
}
}
}
- 姚博文 postgresql listen/notify push message
- PostgreSQL学习第十四篇 listen与notify
- push notify
- Listen to offline message events
- Message vs Notify
- NMHDR = Notify Message Handler
- XMPP message push实现分析
- MQTT message push实现研究
- iPhone上关于Push Notify的实现
- PostgreSQL nonremovable row versions message
- FreeSWITCH技巧:notify与message-waiting
- Listen
- listen
- Listen
- listen()
- (转)ios push message -- Notification
- ActiveMQ: configure PostgreSQL for Message Persistence
- Listen? listen!
- JAVA语法 I - 变量类型
- HashMap最优的循环遍历方式
- java多线程之CyclicBarrier类基本用法
- CString的GetBuffer用法,GetBuffer本质,GetBuffer常见问题解决方法
- MoveWindow and SetWindowPos
- 姚博文 postgresql listen/notify push message
- JAVA语法 II - 访问修饰符
- 堆排序(PHP实现)
- UIScrollView添加手势显示和隐藏键盘
- 注释编译法
- 关于mysql自增字段问题
- hadoop单元测试
- @Override must override a superclass method 问题解决
- 异常-The project: upload_client1 which is referenced by the classpath, does not exist.