IBM Worklight 6.0.0.1 - 推送通知轮询在生产环境中不起作用

时间:2014-01-02 08:09:44

标签: push-notification ibm-mobilefirst worklight-server

我的问题是:

  • 开发环境中,一切正常 - 轮询器工作正常,数据库状态发生变化等。

  • 生产环境时,日志中没有任何内容,数据库中没有任何变化(我正在从数据库表中读取通知)。


推送通知eventSource:

WL.Server.createEventSource({
    name : 'PushEventSource',
    poll : { 
        interval : 360, 
        onPoll : 'sendNotifications' 
    },
    securityTest : 'mobileSecTest' 
});


mobileSecTest安全测试:

<mobileSecurityTest name="mobileSecTest"> 
    <testUser realm="LdapAdapterRealm"/>
    <testDeviceId provisioningType="none"/>
</mobileSecurityTest>


sendNotifications()实施:

var notificationServicesResourceName = "PushAdapter";
function sendNotifications(){

WL.Logger.info('Starting to send notifications');
    var lockInvocationData = {
            adapter : "SQLConnector",
            procedure : "isLocked",
            parameters : [ notificationServicesResourceName ]
    };
    var isLockedResult = WL.Server.invokeProcedure(lockInvocationData);
    if (!isLockedResult.locked) {
        lockInvocationData = {
                adapter : "SQLConnector",
                procedure : "acquireLock",
                parameters : [ notificationServicesResourceName ]
        };
        WL.Server.invokeProcedure(lockInvocationData);

//Get the list of all notifications, from external database
        var dbResponse = getAllUnsentNotifications();

        var data = dbResponse.data ;

        /////////////////THE REST OF THE LONG LONG CODE ////////////
        //Reealse lock
        lockInvocationData = {
                adapter : "SQLConnector",
                procedure : "releaseLock",
                parameters : [ notificationServicesResourceName ]
        };
        WL.Server.invokeProcedure(lockInvocationData);
    }
}


适配器XML文件:

<wl:adapter name="PushAdapter"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:wl="http://www.worklight.com/integration"
    xmlns:http="http://www.worklight.com/integration/http">

    <displayName>PushAdapter</displayName>
    <description>PushAdapter</description>
    <connectivity>
        <connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
            <protocol>http</protocol>
            <domain>${com.ibm.moi.ci.host}</domain>
            <port>${com.ibm.moi.ci.port}</port> 
        </connectionPolicy>
        <loadConstraints maxConcurrentConnectionsPerNode="300" />
    </connectivity>
    <!-- Replace this with appropriate procedures -->
    <procedure name="sendNotifications"/>
    <procedure name="submitNotification"/>

</wl:adapter>

1 个答案:

答案 0 :(得分:1)

所以我现在跑了。 这是一个安全问题。在worklight studio和liberty profile上运行本地工作站上的应用程序时,会禁用某些安全功能,而不是生产。

在开发模式下,没有显式securityTest的所有过程默认都有wl_inprotected我认为他们这样做是为了能够从Eclipse调用过程。在生产环境中,安全性得到增强,wl_unprotected不被视为默认安全测试。

所以我做的是为执行链中的所有过程添加securityTest =“wl_unprotected”,除了sendNotifications过程,该过程应保持不进行sec测试。

就是这样!