当前位置: 首页 > 工具软件 > ZZFLEX > 使用案例 >

java flex 推送,flex 消息推送

吴凯泽
2023-12-01

Flex通过Blazeds利用Remoteservice与后台java消息推送 准备工作:Myeclipse中先建立一个Web project工程,然后导入Blazeds的文件,再转换为Flex项目类型。 前言

messaging-config.xml 文件

true

.

applicationContext.xml 文件

default-channels="my-streaming-amf,my-longpolling-amf,my-polling-amf" />

flex  文件:blazeds推送技术至Flex zz      转自http://www.sloppy.cn/blog/article/247.htm      第一步下载blazeds.war      第二步修改两个配置文件:services-config.xm

message="messageHandler(event.message)"/>

as文件:

consumer.subscribe();

private function messageHandler(message:IMessage):void

{

var siteInfo:ArrayCollection = message.body as ArrayCollection;

var sites:ArrayCollection = siteInfo.getItemAt(0) as ArrayCollection;

/**清空图层数据*/

var keySets :Array = GlobeConfig.getInstance().graphicsLayerHashTable.getKeySet();

for(var k:int =0 ; k < keySets.length ; k++){

var templayer:GraphicsLayer = GlobeConfig.getInstance().graphicsLayerHashTable..find(keySets[k]);

templayer.clear();

}

GlobeConfig.getInstance().graphicHashTable.clear();

for(var a :int = 0 ; a

var gisLocation:GisLocation = sites.getItemAt(a) as GisLocation;

var g:Graphic = new Graphic();

g.geometry = new MapPoint(Number(gisLocation.x),Number(gisLocation.y));

g.symbol = new MonitorSymbol(gisLocation.alias,gisLocation.symbol,gisLocation.items);

g.attributes = gisLocation;

g.toolTip = gisLocation.alias;

g.addEventListener(MouseEvent.CLICK,graphicClickHandler);

var layerHashTable:HashTable = GlobeConfig.getInstance().graphicsLayerHashTable;

var layer:GraphicsLayer = layerHashTable.find(gisLocation.layerid);

if(gisLocation == null){

continue;

}

if(layer != null){

layer.add(g);

GlobeConfig.getInstance().graphicHashTable.add(gisLocation.id,g);

}

}

AppEventDispatcher.getInstance().dispatchEvent(new AppEvent(ArcgisEventConst.REFRESH_GIS_LOCATION_EVENT));

}

java代码:

package com.team.gis.service;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

import org.springframework.flex.messaging.MessageTemplate;

import com.team.gis.domain.GisLocation;

import com.team.gis.domain.MonitorItem;

import com.team.gis.persistence.StationMapper;

public class SimpleFeed {

private final MessageTemplate template;

private StationMapper stationMapper;

public SimpleFeed(MessageTemplate template) {

this.template = template;

}

public void pushSiteInfo(){

List locations = stationMapper.searchGisLocation();

List items = stationMapper.searchMonitorItems();

List aitems = null;

for(GisLocation gisLocation : locations){

if(gisLocation.getMonitor() != null){

String[] ms = gisLocation.getMonitor().split(",");

aitems = new ArrayList();

for(MonitorItem m : items){

for(String mi : ms){

if(m.getId() == Integer.valueOf(mi)){

m.setAvailable(true);

aitems.add(m);

}

}

}

gisLocation.setItems(aitems);

}

}

List> siteInfo = new ArrayList>();

siteInfo.add(locations);

siteInfo.add(items);

template.send("simple-feed",siteInfo);

}

public StationMapper getStationMapper() {

return stationMapper;

}

public void setStationMapper(StationMapper stationMapper) {

this.stationMapper = stationMapper;

}

}

现在有个问题需要大家思考一下,有个已经上线了的项目,有好好几千甚至上万的客户在使用了。现在项目开发商想发布一个通知。在今天下午6点需要重新启动服务器,

 类似资料: