Giter Site home page Giter Site logo

java-mandrill-wrapper's Introduction

For example usage, see the integration tests in src/it/java. You'll need to create a file called mandrill.properties 
and put it somewhere on the classpath. It'll need the following properties.

apiKey=
email.from=
email.to.name1=
email.to.address1=
email.to.name2=
email.to.address2=
verify.email=

java-mandrill-wrapper's People

Contributors

ahapxor avatar aluedeke avatar aphethean1 avatar cribbstechnologies avatar djalexd avatar enalmada avatar ingmontoro avatar martinchooooooo avatar mlavoie-sm360 avatar neosavvy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-mandrill-wrapper's Issues

Deserialize from JSON back to object model

As part of some integration tests, I serlialize the json to file, and then want to deseriliaze back to the object model.

I had to make some minor code changes, by creating no-arg constructors for MandrillRecipient, MergeVar and MandrillAttachment.

Would you be able to make those small changes to master - it would really help alot.

Thanks for the great work!

Spring boot @Bean does not work

I am unable to create an @bean for the MandrillConfiguration object. My attempt at an implementation of this is as follows:

@Configuration
public class MandrillConfig {

    @Value("${mailchimp.apikey}")
    private String API_KEY;

    @Bean
    public MandrillConfiguration getMandrillConfiguration(){
        MandrillConfiguration mandrillConfiguration = new MandrillConfiguration();
        mandrillConfiguration.setApiKey("ptZ7-xBthKB64JK8T8uDbA");
        mandrillConfiguration.setApiVersion("1.0");
        mandrillConfiguration.setBaseURL("https://mandrillapp.com/api");
        return mandrillConfiguration;
    }
}

When using the following:

@Autowired
MandrillConfiguration mandrillconfiguration;

I always get null.
If I am doing something wrong please inform me.

If you are excepting pull request I will contribute if I can fix this issue.

Multi-Thread issue

Hi,

I'm having some problems when I try to send messages in a multi-thread scenario (with the same httpclient instance, using PoolingHttpClientConnectionManager).

After the message is sent in MandrillRESTRequest, the connections aren't closed; when the app reaches the max conn set in httpclient, the messages get blocked and aren't sent.

I fixed it making a copy of MandrillRESTRequest in my working directory and converting HttpClient to CloseableHttpClient (httpclient 4.3.1) and HttpResponse to CloseableHttpResponse, to be able to do this modification:

try {
entity = response.getEntity();
} finally {
response.close();
}
BufferedReader br = new BufferedReader(new InputStreamReader((entity.getContent())));

(this recommendation of closing the connection in a multi-thread environment is detailed here: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e392).

Maybe there's a way to do this connection close without modifying method signature.

MessageResponse breaks after Mandrill addedd new property

Last week Mandrill added a new property in the response to a postRequest.
A property called _id was added.
This makes the method convertAnonymousResponseData break when the objectMapper tries to do readValue.
An error is thrown and this is passed to the application as an IOError.

Suggestion:
Make MessageResponse ignore unknown properties by adding @JsonIgnoreProperties(ignoreUnknown = true)
This way the new _id, and any future additions of properties can be ignored without sending errors to the application

We get the following Exception when we use the API and get an error on the Mandrill side

UnrecognizedPropertyException in MandrillTransactionEmailCommitJob: Json Mapping Exception

com.projecta.framework.backend.util.UnexpectedException: UnrecognizedPropertyException: Json Mapping Exception
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.sendEmail(MandrillTransactionEmailQueue.java:136)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.commit(MandrillTransactionEmailQueue.java:143)
at com.projecta.framework.backend.util.collection.CommittableQueue.commitQueue(CommittableQueue.java:67)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailCommitJob.doRun(MandrillTransactionEmailCommitJob.java:15)
at com.projecta.framework.backend.cronjob.core.CronJobRunner.execute(CronJobRunner.java:68)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Caused by: com.cribbstechnologies.clients.mandrill.exception.RequestFailedException: Json Mapping Exception
at com.cribbstechnologies.clients.mandrill.request.MandrillRESTRequest.performPostRequest(MandrillRESTRequest.java:84)
at com.cribbstechnologies.clients.mandrill.request.MandrillRESTRequest.postRequest(MandrillRESTRequest.java:37)
at com.cribbstechnologies.clients.mandrill.request.MandrillMessagesRequest.sendTemplatedMessage(MandrillMessagesRequest.java:37)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.sendEmail(MandrillTransactionEmailQueue.java:134)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.commit(MandrillTransactionEmailQueue.java:143)
at com.projecta.framework.backend.util.collection.CommittableQueue.commitQueue(CommittableQueue.java:67)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailCommitJob.doRun(MandrillTransactionEmailCommitJob.java:15)
at com.projecta.framework.backend.cronjob.core.CronJobRunner.execute(CronJobRunner.java:68)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

Caused by: org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "reject_reason" (Class com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse), not marked as ignorable
at [Source: java.io.StringReader@7acedf24; line: 1, column: 114](through reference chain: com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse["reject_reason"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:673)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:659)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1365)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:217)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:194)
at org.codehaus.jackson.map.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:30)
at org.codehaus.jackson.map.ObjectMapper._readMapAndClose(ObjectMapper.java:2732)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1870)
at com.cribbstechnologies.clients.mandrill.request.MandrillRESTRequest.convertAnonymousListResponseData(MandrillRESTRequest.java:108)
at com.cribbstechnologies.clients.mandrill.request.MandrillRESTRequest.performPostRequest(MandrillRESTRequest.java:77)
at com.cribbstechnologies.clients.mandrill.request.MandrillRESTRequest.postRequest(MandrillRESTRequest.java:37)
at com.cribbstechnologies.clients.mandrill.request.MandrillMessagesRequest.sendTemplatedMessage(MandrillMessagesRequest.java:37)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.sendEmail(MandrillTransactionEmailQueue.java:134)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailQueue.commit(MandrillTransactionEmailQueue.java:143)
at com.projecta.framework.backend.util.collection.CommittableQueue.commitQueue(CommittableQueue.java:67)
at com.projecta.bobby.commons.mail.transaction.mandrill.MandrillTransactionEmailCommitJob.doRun(MandrillTransactionEmailCommitJob.java:15)
at com.projecta.framework.backend.cronjob.core.CronJobRunner.execute(CronJobRunner.java:68)
at org.quartz.core.JobRunShell.run(JobRunShell.java:213)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

I would add a field to MessageResponse but wanted to ask for your Opinion first.

Licensing

Hey

Could you please drop a MIT license callout so that we could utilize this wrapper in our codebase

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.