Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README.md #102

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,17 +370,6 @@ queue.clear();

--

### Add alerts to a queue. This is for Pull Queue only.

```java
ArrayList<Alert> alerts = new ArrayList<Alert>();
alerts.add(new Alert(Alert.typeProgressive, Alert.directionAscending, 5, "some_q"));
QueueModel info = queue.updateAlerts(alerts);
```

--


## Push Queues

IronMQ push queues allow you to setup a queue that will push to an endpoint, rather than having to poll the endpoint.
Expand Down
80 changes: 0 additions & 80 deletions src/main/java/io/iron/ironmq/Alert.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/io/iron/ironmq/Alerts.java

This file was deleted.

56 changes: 7 additions & 49 deletions src/main/java/io/iron/ironmq/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -693,18 +693,16 @@ public QueueModel create() throws IOException {
* Creates a queue for specified queue client.
* If queue exists, it will be updated.
* @param subscribersList The subscribers list.
* @param alertsList The alerts list.
* @param pushType The push type - multicast or unicast.
* @param errorQueue The name of the error queue to use (can be null)
* @param retries The retries.
* @param retriesDelay The retries delay.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel create(ArrayList<Subscriber> subscribersList, ArrayList<Alert> alertsList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException {
public QueueModel create(ArrayList<Subscriber> subscribersList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException {
QueueModel model = new QueueModel();
model.setPushInfo(new QueuePushModel(subscribersList, retries, retriesDelay, errorQueue));
model.setAlerts(alertsList);
model.setType(pushType);
return create(model);
}
Expand All @@ -713,15 +711,14 @@ public QueueModel create(ArrayList<Subscriber> subscribersList, ArrayList<Alert>
* Creates a queue for specified queue client.
* If queue exists, it will be updated.
* @param subscribersList The subscribers list.
* @param alertsList The alerts list.
* @param pushType The push type - multicast or unicast.
* @param retries The retries.
* @param retriesDelay The retries delay.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel create(ArrayList<Subscriber> subscribersList, ArrayList<Alert> alertsList, String pushType, int retries, int retriesDelay) throws IOException {
return create(subscribersList, alertsList, pushType, "", retries, retriesDelay);
public QueueModel create(ArrayList<Subscriber> subscribersList, String pushType, int retries, int retriesDelay) throws IOException {
return create(subscribersList, pushType, "", retries, retriesDelay);
}

/**
Expand All @@ -744,34 +741,31 @@ public QueueModel create(QueueModel model) throws IOException {
/**
* Update queue. If there is no queue, an EmptyQueueException is thrown.
* @param subscribersList The subscribers list.
* @param alertsList The alerts list.
* @param pushType The push type - multicast or unicast.
* @param errorQueue The name of the error queue to use (can be null)
* @param retries The retries.
* @param retriesDelay The retries delay.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel updateQueue(ArrayList<Subscriber> subscribersList, ArrayList<Alert> alertsList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException {
public QueueModel updateQueue(ArrayList<Subscriber> subscribersList, String pushType, String errorQueue, int retries, int retriesDelay) throws IOException {
QueueModel model = new QueueModel();
model.setPushInfo(new QueuePushModel(subscribersList, retries, retriesDelay, errorQueue));
model.setAlerts(alertsList);
model.setType(pushType);
return update(model);
}

/**
* Update queue. If there is no queue, an EmptyQueueException is thrown.
* @param subscribersList The subscribers list.
* @param alertsList The alerts list.
* @param pushType The push type - multicast or unicast.
* @param retries The retries.
* @param retriesDelay The retries delay.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel updateQueue(ArrayList<Subscriber> subscribersList, ArrayList<Alert> alertsList, String pushType, int retries, int retriesDelay) throws IOException {
return updateQueue(subscribersList, alertsList, pushType, "", retries,retriesDelay);
public QueueModel updateQueue(ArrayList<Subscriber> subscribersList, String pushType, int retries, int retriesDelay) throws IOException {
return updateQueue(subscribersList, pushType, "", retries,retriesDelay);
}

public QueueModel update(QueueModel model) throws IOException {
Expand All @@ -785,59 +779,23 @@ public QueueModel update(QueueModel model) throws IOException {
}

/**
* Add alerts to a queue. If there is no queue, an EmptyQueueException is thrown.
* @param alerts The array list of alerts.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines that should be deleted as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't find these. Did you delete it already?

public QueueModel addAlertsToQueue(ArrayList<Alert> alerts) throws IOException {
return this.updateAlerts(alerts);
}

/**
* Replace current queue alerts with a given list of alerts. If there is no queue, an EmptyQueueException is thrown.
* @param alerts The array list of alerts.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel updateAlertsToQueue(ArrayList<Alert> alerts) throws IOException {
return this.updateAlerts(alerts);
}

/**
* Replace current queue alerts with a given list of alerts. If there is no queue, an EmptyQueueException is thrown.
* @param alerts The array list of alerts.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public QueueModel updateAlerts(ArrayList<Alert> alerts) throws IOException {
QueueModel payload = new QueueModel(alerts);
return this.update(payload);
}

/**
* Delete alerts from a queue. If there is no queue, an EmptyQueueException is thrown.
* @param alert_ids The array list of alert ids.

* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines that should be deleted

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't find these. Did you delete it already?

public void deleteAlertsFromQueue(ArrayList<Alert> alert_ids) throws IOException {
String url = "queues/" + name + "/alerts";
Alerts alert = new Alerts(alert_ids);
String jsonMessages = gson.toJson(alert);
IronReader reader = client.delete(url, jsonMessages);
reader.close();
}

/**
* Delete alert from a queue by alert id. If there is no queue, an EmptyQueueException is thrown.
* @param alert_id The alert id.
* @throws io.iron.ironmq.HTTPException If the IronMQ service returns a status other than 200 OK.
* @throws java.io.IOException If there is an error accessing the IronMQ server.
*/
public void deleteAlertFromQueueById(String alert_id) throws IOException {
String url = "queues/" + name + "/alerts/" + alert_id;
IronReader reader = client.delete(url);
reader.close();
}
}
17 changes: 3 additions & 14 deletions src/main/java/io/iron/ironmq/QueueModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,19 @@ public class QueueModel {
private String project_id;
private Long total_messages;
private QueuePushModel push;
private ArrayList<Alert> alerts;
@SerializedName("message_timeout") private Integer messageTimeout;
@SerializedName("message_expiration") private Integer messageExpiration;

public QueueModel(String id, String name, Integer size, Integer total_messages, String project_id, Integer retries, String pushType, Integer retriesDelay, String errorQueue, ArrayList<Subscriber> subscribers, ArrayList<Alert> alerts) {
public QueueModel(String id, String name, Integer size, Integer total_messages, String project_id, Integer retries, String pushType, Integer retriesDelay, String errorQueue, ArrayList<Subscriber> subscribers) {
this.id = id;
this.name = name;
this.size = (long)size;
this.total_messages = (long)total_messages;
this.project_id = project_id;
this.alerts = alerts;
}

public QueueModel(int messageExpiration, int retries, String pushType, int retries_delay, String error_queue, ArrayList<Subscriber> subscribers, ArrayList<Alert> alerts, int messageTimeout) {
this.messageExpiration = messageExpiration;
this.alerts = alerts;
this.messageTimeout = messageTimeout;
}

Expand All @@ -36,10 +33,6 @@ public QueueModel(int messageTimeout, int messageExpiration) {
this.messageExpiration = messageExpiration;
}

public QueueModel(ArrayList<Alert> alerts) {
this.alerts = alerts;
}

public QueueModel(QueuePushModel push) {
this.push = push;
}
Expand Down Expand Up @@ -187,13 +180,9 @@ public void setSubscribers(ArrayList<Subscriber> subscribers) {
throw new UnsupportedOperationException();
}

public ArrayList<Alert> getAlerts() {
return alerts;
}


public void setAlerts(ArrayList<Alert> alerts) {
this.alerts = alerts;
}


public int getMessageTimeout() {
return messageTimeout;
Expand Down
20 changes: 2 additions & 18 deletions src/test/java/io/iron/ironmq/IronMQTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -656,23 +656,7 @@ public void testUpdateQueuePushParameters() throws IOException {
Assert.assertEquals(url, info.getPushInfo().getSubscribers().get(0).getUrl());
}

/**
* This test shows how to update alerts of a queue
* Expected that:
* - new alert will be available after update
* @throws IOException
*/
@Test
public void testUpdateQueueAlerts() throws IOException {
queue.create();
ArrayList<Alert> alerts = new ArrayList<Alert>();
alerts.add(new Alert(Alert.typeProgressive, Alert.directionAscending, 5, "some_q"));
QueueModel info = queue.updateAlerts(alerts);

Assert.assertEquals(5, info.getAlerts().get(0).getTrigger());
Assert.assertEquals(Alert.directionAscending, info.getAlerts().get(0).getDirection());
Assert.assertEquals(Alert.typeProgressive, info.getAlerts().get(0).getType());
Assert.assertEquals("some_q", info.getAlerts().get(0).getQueue());
sameQueue.getInfoAboutQueue();
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ayodejiola If you delete the whole method - you should delete all the headers and lines. In this case you should delete all the lines between 659 and 677

/**
Expand All @@ -691,11 +675,11 @@ public void testDeleteQueue() throws IOException, InterruptedException {

sameQueue.getInfoAboutQueue();
}

/**
* This test shows how to add subscribers to a queue.
* @throws IOException
*/

@Test
public void testAddSubscribers() throws IOException {
QueueModel payload = new QueueModel();
Expand Down