• theWebDev
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies

We are using the streaming API in our workplace to stream data about certain objects down to our application databases. What we've noticed is that during Salesforce maintenance periods or performance degradation, our communication drops and we do not have a way to reconnect properly at this time. I am curious if anyone else has also had this issue and how they have gone about solving it.

 

Below is an example of the type of error we encounter once teh communication starts to fail. This message repeats until we manually reconnect at this time:

 

2012-06-18 11:59:16,535 [HttpClient-26] INFO org.cometd.client.BayeuxClient@1875064030 - Messages failed [{"id":"24","connectionType":"long-polling","channel":"/meta/connect","clientId":"591o3gs1u56o0t4bqw9r7irb824"}]
java.net.ProtocolException: Unexpected response 401: TransportExchange@1691151590=POST//cs2-api.salesforce.com:443/cometd/24.0/connect#7
at org.cometd.client.BayeuxClient$PublishTransportListener.onProtocolError(BayeuxClient.java:1106)
at org.cometd.client.transport.LongPollingTransport$TransportExchange.onResponseComplete(LongPollingTransport.java:304)
at org.eclipse.jetty.client.HttpExchange$Listener.onResponseComplete(HttpExchange.java:968)
at org.eclipse.jetty.client.HttpExchange.setStatus(HttpExchange.java:279)
at org.eclipse.jetty.client.HttpConnection$Handler.messageComplete(HttpConnection.java:619)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:862)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:214)
at org.eclipse.jetty.client.HttpConnection.handle(HttpConnection.java:275)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:535)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
at java.lang.Thread.run(Unknown Source)

 

Thanks in advance!

Hi everyone,

 

This question is for anyone that has implemented the Salesforce streaming client in Java. I am looking to find sugestions on the proper way to implement reconnect logic for the Java client. The code that is provided by Salesforce (in the StreamingClientExample.java class) has several listener methods that get events which tell the client whether or not a message was successful. In this code, if there is a failure, the client simply exits and I need logic that will attempt to reconnect the client x number of times.

 

>>> CODE PROVIDED BY SALESFORCE

 

        client.getChannel(Channel.META_CONNECT).addListener(
            new ClientSessionChannel.MessageListener() {
            public void onMessage(ClientSessionChannel channel, Message message) {

                System.out.println("[CHANNEL:META_CONNECT]: " + message);

                boolean success = message.isSuccessful();
                if (!success) {
                    String error = (String) message.get("error");
                    if (error != null) {
                        System.out.println("Error during CONNECT: " + error);
                        System.out.println("Exiting...");
                        System.exit(1);
                    }
                }
            }
        });

 

I am considering putting the reconnect CALL in this method, like in the sample below, and I am wondering if anyone has done this and has come accross any issues with doing it this way. In particular, the kind of issues I am trying to avoid are inefficient loops where the client keeps trying to connect and fails, any threading issues, etc.

 

>>>> PROPOSED RECONNECT CALL:

 

    public void addConnectListener(BayeuxClient client) {
        client.getChannel(Channel.META_CONNECT).addListener(
                new ClientSessionChannel.MessageListener() {
                    public void onMessage(ClientSessionChannel channel,
                            Message message) {

                        logger.info("[CHANNEL:META_CONNECT]: " + message);

                        boolean success = message.isSuccessful();
                        if (!success) {
                            String error = (String) message.get("error");
                            if (error != null) {
                                logger.error("Error during CONNECT: " + error);

                                exception = true;
                                try {
                                    reconnect(message);
                                } catch (FatalStreamingErrorException e) {
                                    throw new RuntimeException(e.getMessage());
                                }
                            }
                        }
                    }
                });
    }

 

Thanks in advance!

Hello,

 

I am unable to add the field "Email Opt Out" (API name "HasOptedOutOfEmail") to our Lead page layout in our Sandbox environment.  The strange thing is, when i click "Edit Layout" and attempt to add "Email Opt Out" to the layout, it appears in the layout editing view as it should along with the rest of the fields, but when I save it, it does not show up in the actual layout.

 

This is causing problems during development because my orginization is using the Partner WSDL, and as such we can only access object fields that are in the page layout for that object.  So "Email Opt Out" does not exist as a valid field in the WSDL, and when I try to create or update a Lead with a value in the "HasOptedOutOfEmail" API field, I get a INVALID_FIELD_FOR_INSERT_UPDATE exception.

 

Any ideas, or anyone run into this before?  I would appreciate any help, except for just saying "well then just use the Enterprise client!" -- this is not feasible in our organization right now because our entire Salesforce library was written to use the Partner API.

 

Thank you!

SB

Hello,

 

I have a Date/Time field named Expire_Date that I want to be set to thirty days after CreatedDate.  This seems straightforward; here's what I have in the forumula textarea:

 

 

CreatedDate + 30

 

 Should, work right?  However when I create new objects (it's a "Quote" object), the field is blank.  Do I have to perhaps do something explicitly on object create that will populate this field?

 

Thank you in advance for any help!

 

 

Hello,

 

I am unable to add the field "Email Opt Out" (API name "HasOptedOutOfEmail") to our Lead page layout in our Sandbox environment.  The strange thing is, when i click "Edit Layout" and attempt to add "Email Opt Out" to the layout, it appears in the layout editing view as it should along with the rest of the fields, but when I save it, it does not show up in the actual layout.

 

This is causing problems during development because my orginization is using the Partner WSDL, and as such we can only access object fields that are in the page layout for that object.  So "Email Opt Out" does not exist as a valid field in the WSDL, and when I try to create or update a Lead with a value in the "HasOptedOutOfEmail" API field, I get a INVALID_FIELD_FOR_INSERT_UPDATE exception.

 

Any ideas, or anyone run into this before?  I would appreciate any help, except for just saying "well then just use the Enterprise client!" -- this is not feasible in our organization right now because our entire Salesforce library was written to use the Partner API.

 

Thank you!

SB