0

Hi, I m trying example from http://www.mulesoft.org/connectors/es... But it is giving following Exception . Caused by:

twitter4j.internal.org.json.JSONException: A JSONArray text must start with '[' at 1 [character 2 line 1] at twitter4j.internal.org.json.JSONTokener.syntaxError(JSONTokener.java:335) at twitter4j.internal.org.json.JSONArray.(JSONArray.java:107) at twitter4j.internal.http.HttpResponse.asJSONArray(HttpResponse.java:185) ... 54 more

anybody tried the same example. or anybody have solution. Thank You.

Francois Borgies
  • 2,378
  • 31
  • 38
Pramod R
  • 73
  • 1
  • 6

1 Answers1

1

There seems to be some sort of issue regarding the twitter connector while using the get-home-timeline operation (I just filed a jira for it).

I've managed to do a simple mule app using just the Esper connector to test it, and it is working properly. Let me know if this helps (the code is below)

file: esper-config.xml

<esper-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.espertech.com/schema/esper" xsi:schemaLocation=" http://www.espertech.com/schema/esper http://www.espertech.com/schema/esper/esper-configuration-2.0.xsd">
    <event-type name="Person" class="org.mule.Person"/>
</esper-configuration>

file: Person.java

package org.mule;

import java.io.Serializable;

public class Person implements Serializable {
    private static final long serialVersionUID = 1L;
    private String name;
    private Integer age;

    public Person(String name, Integer age) {
        super();
        this.name = name;
        this.age = age;
    }

    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    public Integer getAge() { return age; }
    public void setAge(Integer age) { this.age = age; }
}

file: simple_esper.xml

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:json="http://www.mulesoft.org/schema/mule/json"
    xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
    xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:esper="http://www.mulesoft.org/schema/mule/esper" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/esper http://www.mulesoft.org/schema/mule/esper/1.0/mule-esper.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">

   <esper:config name="Esper" configuration="esper-config.xml" doc:name="Esper"/>


   <flow name="Esper_saving_people" doc:name="Esper_saving_people">
        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
        <scripting:component doc:name="People creation">
            <scripting:script engine="Groovy"><![CDATA[def persons=[];
persons.add(new org.mule.Person("mule", 23));
persons.add(new org.mule.Person("ESB", 42));
persons.add(new org.mule.Person("mule", 42));
return persons;]]></scripting:script>
        </scripting:component>
        <foreach doc:name="Iteragint over people">
            <esper:send config-ref="Esper" eventPayload-ref="#[payload]" eventName="people" doc:name="Esper"/>
        </foreach>
        <json:object-to-json-transformer doc:name="Object to JSON"/>
    </flow>

    <flow name="Esper_amount_of_people" doc:name="Esper_amount_of_people">
        <esper:listen config-ref="Esper" statement="select count(*) from Person" doc:name="Esper (Streaming)"/>
        <logger message="Esper, amount of people: #[payload]" level="INFO"    doc:name="Logger"/>
    </flow> 

    <flow name="Esper_average_age" doc:name="Esper_other_listen">
        <esper:listen config-ref="Esper" statement="select avg(age) from Person " doc:name="Esper (Streaming)"/>
        <logger message="Esper, average age: #[payload]" level="INFO"    doc:name="Logger"/>
    </flow> 

</mule>

Cheers, Lautaro