Hi Antonio,

On Fri, Jul 25, 2014 at 5:57 PM, Antonio Jesus Navarro <
[email protected]> wrote:

> Hi all,
>
> We need in our project the remove callback functionality. Because is not
> implemented, we was intended to do an small workaround:
>
> - The normal creation of parent stream:
>
>         StreamDefinition newStream = 
> QueryFactory.createStreamDefinition().name(STREAM_NAME);
>         newStream.attribute("col1", Type.STRING);
>         newStream.attribute("col2", Type.INT);
>         sm.defineStream(newStream);
>
> - Here is the trick. When a callback is added to stream, we generate a
> query on the fly because callbacks can be associated to queries:
>
>         String actionQueryId = 
> sm.addQuery(QueryFactory.createQuery().from(QueryFactory.inputStream(STREAM_NAME)));
>
>         sm.addCallback(actionQueryId, new DummyQueryCallback());
>
> - Dummy implementation of QueryCallback:
>
> public class DummyQueryCallback extends QueryCallback {
>     @Override
>     public void receive(long timeStamp, Event[] inEvents, Event[] 
> removeEvents) {
>         callbackCalled.set(Boolean.TRUE);
>     }
> }
>
> - So far so good, all works great. Events are sending correctly to
> callback. But when we intend to drop this query, a NullPointerException
> appears from QueryManager, line 148:
>
> streamTableDefinitionMap.remove(query.getOutputStream().getStreamId());
>
> We have a few questions:
>
> - Can you help us with this workaround?
>


Null pointer exception occurs since the query you have defined does not
contain an output ('insert into') clause. You can fix it by doing something
like following - i.e. use 'insert into' to define a stream to output the
events:

        String actionQueryId =
sm.addQuery(QueryFactory.createQuery().from(QueryFactory.inputStream(STREAM_NAME)).insertInto("outStream"));

Refer to this doc [1] which explains the parts of a simple pass-through
query for more details.



> - It's possible request a "dropCallback" functionality?
>


You can create a public jira [2] to request new features. They will get
added to the next version of the product if they are useful/relevant
features.


[1[ https://docs.wso2.com/display/CEP310/Pass-through
[2] https://wso2.org/jira/browse/CEP


Thanks
Rajeev


> We add an attachment with an small issue test.
>
> Thanks in advance.
>
> _______________________________________________
> Architecture mailing list
> [email protected]
> https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture
>
>


-- 
Rajeev Sampath
Senior Software Engineer
WSO2, Inc.; http://www.wso2.com.

Mobile:
* +94716265766*
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to