2
    paymentsRequest.stream(new EventListener<OperationResponse>() {
        @Override
        public void onEvent(OperationResponse payment) {
            System.out.println("TEST TEST TEST");

This does not print anything. Never. No incoming, no outgoing TX. Tried to supply both private KeyPair and KeyPair created using public accountId only. And yes I do import correct EventListener:

import org.stellar.sdk.requests.EventListener;
import org.stellar.sdk.requests.PaymentsRequestBuilder;

Other operations like balance, tx history, search tx by hash, sign & send tx works without any problems. I'm using a week old github sourcecode.

EDIT: and the link is working https://horizon.stellar.org/accounts/GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB/payments

1

Not sure if you were running into a bug, but the following basic code does work and shows how you can use streaming with the Java SDK. This was tested with the Stellar Java SDK 0.6.0, which you can grab here.

package playground;

import org.stellar.sdk.KeyPair;
import org.stellar.sdk.Server;
import org.stellar.sdk.requests.EventListener;
import org.stellar.sdk.requests.PaymentsRequestBuilder;
import org.stellar.sdk.responses.operations.OperationResponse;

public class App {
    public static void streamPayments() {
        Server server = new Server("https://horizon.stellar.org");
        KeyPair account = KeyPair.fromAccountId(
                "GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB");
        PaymentsRequestBuilder paymentsRequest = server.payments().forAccount(account);
        paymentsRequest.stream(new EventListener<OperationResponse>() {
            @Override
            public void onEvent(OperationResponse event) {
                String fmt = String.format(
                        "ID: %s Created At: %s\nOperation Type: %s\nSource Account: %s\n" +
                        "TxHash: %s\nSuccess?: %s\n\n", event.getId(), event.getCreatedAt(),
                        event.getType(), event.getSourceAccount().getAccountId(),
                        event.getTransactionHash(), event.isTransactionSuccessful());
                System.out.println(fmt);
            }
        });
    }

    public static void main(String[] args) {
        streamPayments();
    }
}

In fact, it prints out the following:

ID: 89778702115696641 Created At: 2018-11-09T19:21:20Z
Operation Type: create_account
Source Account: GA5XIGA5C7QTPTWXQHY6MCJRMTRZDOSHR6EFIBNDQTCQHG262N4GGKTM
TxHash: e900a099a3c2d3ba5b2a51240b26e71fc5a92d96a7b35fa0b143c26e5e05c6a6
Success?: true


ID: 89957716352622593 Created At: 2018-11-12T08:58:50Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 9ca53a6dfc57f583d0deef2c60e7b0bb18f844399167b83d439a13c31b5da95a
Success?: true


ID: 90043156137000961 Created At: 2018-11-13T14:22:06Z
Operation Type: create_account
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 5ff19b1adf7265ea338aabbd515260109645b188dac0c692080a4784dbb69c6d
Success?: true


ID: 90043448194768897 Created At: 2018-11-13T14:27:47Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: e5305eaa6900e633391d0edcf9676344584a9c74768dc55a22f32854928b17b4
Success?: true


ID: 90740701775593473 Created At: 2018-11-23T13:34:39Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: e9f9c409a1f2b22b7161b6aaf45909f51d3ecb6706dc8dbb77dd7f15082a2bd8
Success?: true


ID: 90742140589621249 Created At: 2018-11-23T14:02:50Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 624fcd3872588007768660e9d8bc19f0bdca55dd3a8605bd25ba8703da5bc53a
Success?: true


ID: 90742278028529665 Created At: 2018-11-23T14:05:31Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 5a487ab1fd6db4564c4549ec4b63489156d85867b000e99057853317755f5e37
Success?: true


ID: 90742415467511809 Created At: 2018-11-23T14:08:12Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: c70ec25250a6bb7eb4f9037a820f5dd8167c17ffa1afb1059ff5526c787cf59d
Success?: true


ID: 90742454122237953 Created At: 2018-11-23T14:08:57Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: d89ec9437890169da5b4e4e360c619794593df51cd8d029a6d0db977ae291367
Success?: true


ID: 90742711820300289 Created At: 2018-11-23T14:14:01Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 975df76798e76f714d6c23bf9c768fafdd7c0945fdc2c67e1852b69a70e261b9
Success?: true


ID: 90742724705202177 Created At: 2018-11-23T14:14:16Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 5f4a5d61c062640bcb1ee4423b297471d89f7bd5c4df171c1676949da803916d
Success?: true


ID: 90742853554184193 Created At: 2018-11-23T14:16:46Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 2a477ec03c03e995eef17d530fc8ce88dc87e0abd2a2061de41855c32ff072f1
Success?: true


ID: 91011495168610305 Created At: 2018-11-27T10:34:26Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 7d88467d76e5dd3428ada61a49abe12587c60032056d38947eca2f8fefc0c289
Success?: true


ID: 91011533823283201 Created At: 2018-11-27T10:35:22Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 94cbd7cd09b69eab900788190f63cd3085247f471c06cb696b5eff7e38b83aeb
Success?: true


ID: 91015936164810753 Created At: 2018-11-27T12:09:32Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 27b2264a5118c6bde1eaa86eef0b8dc5eff425be6e566f33729d864243fdacc7
Success?: true


ID: 91019247584591873 Created At: 2018-11-27T13:14:20Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: cf7f2016fdddc864ce00b33aaa2f813c9bc21d306c82aa1fe128807d0bfb6519
Success?: true


ID: 91019793045426177 Created At: 2018-11-27T13:25:00Z
Operation Type: payment
Source Account: GBBKXF2HOGIVFLYY5AQOJ4ER2D5JPK4IQDQTSZ6WHKTH6C6HPQWFA2LB
TxHash: 616a916ae96436f8ed1c93aae29aaf025675a4891e8056664de8eaac67cb4076
Success?: true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.